Compare commits
13 Commits
b5d79e2b57
...
main
Author | SHA1 | Date | |
---|---|---|---|
8d950c5704 | |||
|
cad9726d0d | ||
|
4c54ba5d4b | ||
|
1d523ed097 | ||
|
a64040170a | ||
|
59998680ad | ||
|
8429d5d7ae | ||
|
dd5284972c | ||
|
ba814ad400 | ||
|
238759ad89 | ||
|
8c5e3a705a | ||
|
a86661a37a | ||
|
929832b3aa |
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -1,5 +1,5 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="21" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="openjdk-22" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
BIN
Medien/Bilder/HackerUnicorn.png
Normal file
BIN
Medien/Bilder/HackerUnicorn.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.0 MiB |
BIN
Medien/Bilder/HackerUnicorn_Schäbig.png
Normal file
BIN
Medien/Bilder/HackerUnicorn_Schäbig.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 210 KiB |
BIN
Medien/Bilder/info_I.png
Normal file
BIN
Medien/Bilder/info_I.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 750 B |
BIN
Medien/Bilder/info_I_tiny.png
Normal file
BIN
Medien/Bilder/info_I_tiny.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 469 B |
5
Medien/Dokumente/Anmerkung.txt
Normal file
5
Medien/Dokumente/Anmerkung.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
Moodle meldet beim Versuch die Word-Datei einzufügen einen Fehler "Verbindung zum Server verloren"
|
||||||
|
daher die Abgabe im PDF Format.
|
||||||
|
Die Word Datei ist bei Gitea hochgeladen und kann dort heruntergeladen werden.
|
||||||
|
|
||||||
|
https://gitea.hb.dhbw-stuttgart.de/vanBos/S2_Aufgaben/src/branch/main/Medien/Dokumente/Abgabe%2014.05.24.docx
|
BIN
Medien/Folien/Programmieren_15_Swing_1.pdf
Normal file
BIN
Medien/Folien/Programmieren_15_Swing_1.pdf
Normal file
Binary file not shown.
@@ -16,7 +16,8 @@
|
|||||||
- c) Java built-in generic Stack
|
- c) Java built-in generic Stack
|
||||||
- VL 3 Aufgabe 2 (Dynamischer Speicher einer Queue)
|
- VL 3 Aufgabe 2 (Dynamischer Speicher einer Queue)
|
||||||
- VL 3 Aufgabe 3 (ArrayList vs LinkedList)
|
- VL 3 Aufgabe 3 (ArrayList vs LinkedList)
|
||||||
|
- VL 4 Aufgabe 1 (Threads counting)
|
||||||
|
- VL 4 Aufgabe 2 (User - Printer)
|
||||||
|
|
||||||
- keine
|
- keine
|
||||||
|
|
||||||
|
@@ -2,15 +2,11 @@
|
|||||||
// then press Enter. You can now see whitespace characters in your code.
|
// then press Enter. You can now see whitespace characters in your code.
|
||||||
|
|
||||||
import part3.aufg3.Anwendung;
|
import part3.aufg3.Anwendung;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int size;
|
System.out.println("I am Main!");
|
||||||
int MAX_LENGTH = 3;
|
|
||||||
int MIN_LENGTH = 10;
|
|
||||||
|
|
||||||
for (int i = 0; i <25; i++) {
|
|
||||||
size = (int) (Math.random() * MAX_LENGTH);
|
|
||||||
System.out.println(size);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -57,7 +57,7 @@ public class Anwendung {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
int stringsToAdd = 500_000;
|
int stringsToAdd = 1000_000;
|
||||||
long totalTimeSpent = 0;
|
long totalTimeSpent = 0;
|
||||||
int measurements = 10;
|
int measurements = 10;
|
||||||
|
|
||||||
|
14
src/part5/Demo.java
Normal file
14
src/part5/Demo.java
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package part5;
|
||||||
|
|
||||||
|
public class Demo {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// for (int i = 0; i < 2; i++) {
|
||||||
|
// Window w = new Window("My Java GUI");
|
||||||
|
// w.display();
|
||||||
|
// }
|
||||||
|
|
||||||
|
aufg gudWindow = new aufg("Mein Geniales GUI", 400, 340);
|
||||||
|
gudWindow.loadDesign2();
|
||||||
|
gudWindow.display(true);
|
||||||
|
}
|
||||||
|
}
|
88
src/part5/Window.java
Normal file
88
src/part5/Window.java
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
package part5;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.text.html.HTMLEditorKit;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.awt.event.WindowListener;
|
||||||
|
|
||||||
|
public class Window {
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
public Window(String title){
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JFrame setup(int height, int width){
|
||||||
|
JFrame w = new JFrame();
|
||||||
|
w.setVisible(true);
|
||||||
|
w.setSize(width,height);
|
||||||
|
w.setTitle(this.title);
|
||||||
|
w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void display() {
|
||||||
|
JFrame w = setup(700,700);
|
||||||
|
|
||||||
|
JPanel contentPane = new JPanel();
|
||||||
|
|
||||||
|
JButton textFeld = new JButton("Ich bin eine Beschriftung und lebe in einem Button");
|
||||||
|
contentPane.add(textFeld);
|
||||||
|
|
||||||
|
JTextField text = new JFormattedTextField("Hello, I am a formatted Text field \nThis Linebreak may work");
|
||||||
|
contentPane.add(text);
|
||||||
|
|
||||||
|
JLabel vorname = new JLabel("Vorname");
|
||||||
|
JLabel nachname = new JLabel("Nachname");
|
||||||
|
JLabel MatrikelNr = new JLabel("MatrikelNR.");
|
||||||
|
JLabel password = new JLabel("Passwort");
|
||||||
|
JLabel longText = new JLabel("Langer Text");
|
||||||
|
|
||||||
|
JTextField feldVorName = new JTextField(10);
|
||||||
|
JTextField feldNachName = new JTextField(10);
|
||||||
|
JPasswordField feldPassw = new JPasswordField(10);
|
||||||
|
JTextArea feldLongText = new JTextArea(20,15);
|
||||||
|
|
||||||
|
contentPane.add(vorname);
|
||||||
|
contentPane.add(feldVorName);
|
||||||
|
contentPane.add(nachname);
|
||||||
|
contentPane.add(feldNachName);
|
||||||
|
contentPane.add(password);
|
||||||
|
contentPane.add(feldPassw);
|
||||||
|
|
||||||
|
Icon i = new ImageIcon("Medien/Bilder/HackerUnicorn_Schäbig.png");
|
||||||
|
JButton grafik = new JButton(i);
|
||||||
|
contentPane.add(grafik);
|
||||||
|
|
||||||
|
contentPane.add((MatrikelNr));
|
||||||
|
contentPane.add(longText);
|
||||||
|
contentPane.add(feldLongText);
|
||||||
|
|
||||||
|
|
||||||
|
w.setContentPane(contentPane);
|
||||||
|
|
||||||
|
|
||||||
|
JMenuBar menuebar = new JMenuBar();
|
||||||
|
JMenu file = new JMenu("file");
|
||||||
|
JMenu help = new JMenu("help");
|
||||||
|
|
||||||
|
menuebar.add(file);
|
||||||
|
menuebar.add(help);
|
||||||
|
|
||||||
|
JMenuItem fileOpen = new JMenuItem("open");
|
||||||
|
JMenuItem fileClose = new JMenuItem("close");
|
||||||
|
JMenuItem fileEdit = new JMenuItem("edit");
|
||||||
|
JMenuItem helpInfo = new JMenuItem("info");
|
||||||
|
JMenuItem helpUnsub = new JMenuItem("unsubscribe");
|
||||||
|
|
||||||
|
file.add(fileOpen);
|
||||||
|
file.add(fileEdit);
|
||||||
|
file.add(fileClose);
|
||||||
|
help.add(helpInfo);
|
||||||
|
help.add(helpUnsub);
|
||||||
|
|
||||||
|
w.setJMenuBar(menuebar);
|
||||||
|
}
|
||||||
|
}
|
246
src/part5/aufg.java
Normal file
246
src/part5/aufg.java
Normal file
@@ -0,0 +1,246 @@
|
|||||||
|
package part5;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
|
||||||
|
public class aufg {
|
||||||
|
private String title;
|
||||||
|
private int height;
|
||||||
|
private int width;
|
||||||
|
private JFrame window;
|
||||||
|
private JPanel contentPane;
|
||||||
|
private JMenuBar menubar;
|
||||||
|
|
||||||
|
public aufg(String title, int height, int width){
|
||||||
|
this.title = title;
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
this.window = new JFrame();
|
||||||
|
this.contentPane = new JPanel();
|
||||||
|
this.menubar = new JMenuBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void display(boolean exitOnClose){
|
||||||
|
this.window.setTitle(this.title);
|
||||||
|
this.window.setSize(this.width, this.height);
|
||||||
|
this.window.setContentPane(this.contentPane);
|
||||||
|
this.window.setVisible(true);
|
||||||
|
|
||||||
|
if (exitOnClose){
|
||||||
|
this.window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadDesign2(){
|
||||||
|
addMenuBar();
|
||||||
|
addLabel("Von");
|
||||||
|
addLabeledTextField("Bahnhof/Haltestelle", false);
|
||||||
|
addImage("Medien/Bilder/info_I_tiny.png");
|
||||||
|
addLabel("Nach");
|
||||||
|
addLabeledTextField("Bahnhof/Haltestelle", false);
|
||||||
|
addButton("über");
|
||||||
|
addLabel("Hinfahrt");
|
||||||
|
addLabeledTextField("Datum", false);
|
||||||
|
addLabel("Rückfahrt");
|
||||||
|
addLabeledTextField("Uhrzeit", false);
|
||||||
|
// addDropdown(values = {"Abfahrt", "Ankunft"})
|
||||||
|
addLabeledTextField("Uhrzeit", false);
|
||||||
|
// addDropdown(values = {"Abfahrt", "Ankunft"})
|
||||||
|
addLabel("Angaben zur Preisberechnung");
|
||||||
|
addLabel("Reisende");
|
||||||
|
// addDropdown(values = {"1 Erwachsener", "1 Student"})
|
||||||
|
// addDropdown(values = {"Keine Ermäßigung", "20% Rabatt"})
|
||||||
|
// addDropDown(values = {"2. Klasse", "1. Klasse"})
|
||||||
|
addButton("Personen Hinzufügen");
|
||||||
|
addImage("Medien/Bilder/info_I_tiny.png");
|
||||||
|
addButton("Auslandspreise");
|
||||||
|
addImage("Medien/Bilder/info_I_tiny.png");
|
||||||
|
addLabel("Angaben zur Verbindung");
|
||||||
|
addLabel("Verkehrsmittel: ");
|
||||||
|
// addDropDown(values = {"Standartsuche", "Spezialsuche"})
|
||||||
|
addButton("Erweitert");
|
||||||
|
addImage("Medien/Bilder/info_I_tiny.png");
|
||||||
|
// addCheckBox(label = "schnelle Verbindung bevorzugen")
|
||||||
|
addImage("Medien/Bilder/info_I_tiny.png");
|
||||||
|
// addCheckBox(label = "Fahrradmitnahme")
|
||||||
|
addButton("Verbindung Suchen");
|
||||||
|
addButton("Neue Anfrage");
|
||||||
|
addButton("Mein Anfrageprofil");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadDesign(){
|
||||||
|
addMenuBar();
|
||||||
|
addLabeledTextField("TextBox", true);
|
||||||
|
addLabeledPasswordField("Password", true);
|
||||||
|
addImage("Medien/Bilder/info_I_tiny.png");
|
||||||
|
addImage("Medien/Bilder/HackerUnicorn_Schäbig.png");
|
||||||
|
addLabeledRadioButtons("First Set of radiobuttons", new String[] {"Option1", "Choice2", "Variant3"}, true);
|
||||||
|
addLabeledRadioButtons("Second Group of Options", new String[] {"Maybe this?", "Or that"}, true);
|
||||||
|
// popUpInputText(new String[] {"Choice1", "Option2"});
|
||||||
|
popUpDropDown("Medien/Bilder/info_I_tiny.png",
|
||||||
|
"Title of my Window",
|
||||||
|
"choose your favourite",
|
||||||
|
new String[] {"Choice1", "Option2"},
|
||||||
|
"Option2");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMenuBar(){
|
||||||
|
JMenu file = new JMenu("File");
|
||||||
|
JMenuItem fileOpen = new JMenuItem("Open");
|
||||||
|
JMenuItem fileEdit = new JMenuItem("Edit");
|
||||||
|
JMenuItem fileClose = new JMenuItem("Close");
|
||||||
|
file.add(fileOpen);
|
||||||
|
file.add(fileEdit);
|
||||||
|
file.add(fileClose);
|
||||||
|
|
||||||
|
JMenu help = new JMenu("Help");
|
||||||
|
JMenuItem helpInfo = new JMenuItem("Info");
|
||||||
|
JMenuItem helpUnsub = new JMenuItem("Unsubscribe");
|
||||||
|
help.add(helpInfo);
|
||||||
|
help.add(helpUnsub);
|
||||||
|
|
||||||
|
JMenu english = new JMenu("English");
|
||||||
|
JMenuItem englishChangeTo = new JMenuItem("Change to English");
|
||||||
|
english.add(englishChangeTo);
|
||||||
|
|
||||||
|
JMenu braile = new JMenu("Braile");
|
||||||
|
JMenuItem braileChangeTo = new JMenuItem("Change to Braile");
|
||||||
|
braile.add(braileChangeTo);
|
||||||
|
|
||||||
|
this.menubar.add(file);
|
||||||
|
this.menubar.add(help);
|
||||||
|
this.menubar.add(english);
|
||||||
|
this.menubar.add(braile);
|
||||||
|
|
||||||
|
this.window.setJMenuBar(this.menubar);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLabel(String text){
|
||||||
|
this.contentPane.add(makeLabel(text));
|
||||||
|
}
|
||||||
|
public JLabel makeLabel(String text){
|
||||||
|
return new JLabel(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTextField(int columns){
|
||||||
|
this.contentPane.add(makeTextField(columns));
|
||||||
|
}
|
||||||
|
public JTextField makeTextField(int columns){
|
||||||
|
return new JTextField(columns);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLabeledTextField(String labelText, boolean makeVertical){
|
||||||
|
this.contentPane.add(makeLabeledTextField(labelText,makeVertical));
|
||||||
|
}
|
||||||
|
public Box makeLabeledTextField(String labelText, boolean makeVertical){
|
||||||
|
Box b;
|
||||||
|
|
||||||
|
if (makeVertical) {
|
||||||
|
b = Box.createVerticalBox();
|
||||||
|
}else{
|
||||||
|
b = Box.createHorizontalBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
b.add(makeLabel(labelText));
|
||||||
|
b.add(makeTextField(10));
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPasswordField(){
|
||||||
|
this.contentPane.add(makePasswordField());
|
||||||
|
}
|
||||||
|
public JPasswordField makePasswordField(){
|
||||||
|
return new JPasswordField(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLabeledPasswordField(String label, boolean makeVertical){
|
||||||
|
this.contentPane.add(makeLabeledPasswordField(label,makeVertical));
|
||||||
|
}
|
||||||
|
public Box makeLabeledPasswordField(String label, boolean makeVertical){
|
||||||
|
Box b;
|
||||||
|
|
||||||
|
if (makeVertical) {
|
||||||
|
b = Box.createVerticalBox();
|
||||||
|
}else{
|
||||||
|
b = Box.createHorizontalBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
b.add(makeLabel(label));
|
||||||
|
b.add(makePasswordField());
|
||||||
|
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTextArea(int rows, int cols){
|
||||||
|
this.contentPane.add(makeTextArea(rows, cols));
|
||||||
|
}
|
||||||
|
public JTextArea makeTextArea(int rows, int cols){
|
||||||
|
return new JTextArea(rows, cols);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addImage(String link){
|
||||||
|
this.contentPane.add(makeImage(link));
|
||||||
|
}
|
||||||
|
public JButton makeImage(String link){
|
||||||
|
Icon i = new ImageIcon(link);
|
||||||
|
return new JButton(i);
|
||||||
|
}
|
||||||
|
public void addRadioButtons(String[] options){
|
||||||
|
this.contentPane.add(makeRadioButtons(options));
|
||||||
|
}
|
||||||
|
public Box makeRadioButtons(String[] options){
|
||||||
|
Box b = Box.createVerticalBox();
|
||||||
|
ButtonGroup group = new ButtonGroup();
|
||||||
|
// this.contentPane.setLayout(new FlowLayout()); Don't know what this does,
|
||||||
|
// Can't be bothered to look it up
|
||||||
|
// Can be bothered to type this tho
|
||||||
|
|
||||||
|
for (String option: options){
|
||||||
|
JRadioButton button = new JRadioButton(option);
|
||||||
|
b.add(button);
|
||||||
|
group.add(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
b.add(Box.createVerticalStrut(10));
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addButton(String text){
|
||||||
|
this.contentPane.add(makeButton(text));
|
||||||
|
}
|
||||||
|
public JButton makeButton(String text){
|
||||||
|
return new JButton(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLabeledRadioButtons(String label, String[] options, boolean makeVertical){
|
||||||
|
this.contentPane.add(makeLabeledRadioButtons(label, options, makeVertical));
|
||||||
|
}
|
||||||
|
public Box makeLabeledRadioButtons(String label, String[] options, boolean makeVertical){
|
||||||
|
Box b;
|
||||||
|
|
||||||
|
if (makeVertical) {
|
||||||
|
b = Box.createVerticalBox();
|
||||||
|
}else{
|
||||||
|
b = Box.createHorizontalBox();
|
||||||
|
}
|
||||||
|
b.add(makeLabel(label));
|
||||||
|
b.add(makeRadioButtons(options));
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String popUpInputText(String[] values){
|
||||||
|
return (String) JOptionPane.showInputDialog(this.contentPane, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String popUpDropDown(String iconLink, String title, String message, String[] values, String initialSelection){
|
||||||
|
return (String) JOptionPane.showInputDialog(
|
||||||
|
this.contentPane,
|
||||||
|
message,
|
||||||
|
title,
|
||||||
|
JOptionPane.INFORMATION_MESSAGE,
|
||||||
|
new ImageIcon(iconLink),
|
||||||
|
values,
|
||||||
|
initialSelection);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user