Add LabeledRadioButtons
This commit is contained in:
parent
8429d5d7ae
commit
59998680ad
@ -1,8 +1,6 @@
|
|||||||
package part5;
|
package part5;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
|
|
||||||
|
|
||||||
public class aufg {
|
public class aufg {
|
||||||
@ -34,15 +32,13 @@ public class aufg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadDesign(){
|
public void loadDesign(){
|
||||||
addLabeledTextField("TextBox", false);
|
|
||||||
addMenuBar();
|
addMenuBar();
|
||||||
addPasswordField();
|
addLabeledTextField("TextBox", true);
|
||||||
|
addLabeledPasswordField("Password", true);
|
||||||
addImage("Medien/Bilder/info_I.png");
|
addImage("Medien/Bilder/info_I.png");
|
||||||
addImage("Medien/Bilder/HackerUnicorn_Schäbig.png");
|
addImage("Medien/Bilder/HackerUnicorn_Schäbig.png");
|
||||||
addLabel("First Set of Radiobuttons");
|
addLabeledRadioButtons("First Set of radiobuttons", new String[] {"Option1", "Choice2", "Variant3"}, true);
|
||||||
addRadioButtons(new String[] {"Option1", "Choice2", "Variant3"});
|
addLabeledRadioButtons("Second Group of Options", new String[] {"Maybe this?", "Or that"}, true);
|
||||||
addLabel("Second Group of Options");
|
|
||||||
addRadioButtons(new String[] {"Maybe this?", "Or that"});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMenuBar(){
|
public void addMenuBar(){
|
||||||
@ -80,16 +76,14 @@ public class aufg {
|
|||||||
this.contentPane.add(makeLabel(text));
|
this.contentPane.add(makeLabel(text));
|
||||||
}
|
}
|
||||||
public JLabel makeLabel(String text){
|
public JLabel makeLabel(String text){
|
||||||
JLabel label = new JLabel(text);
|
return new JLabel(text);
|
||||||
return label;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTextField(int columns){
|
public void addTextField(int columns){
|
||||||
this.contentPane.add(makeTextField(columns));
|
this.contentPane.add(makeTextField(columns));
|
||||||
}
|
}
|
||||||
public JTextField makeTextField(int columns){
|
public JTextField makeTextField(int columns){
|
||||||
JTextField textField = new JTextField(columns);
|
return new JTextField(columns);
|
||||||
return textField;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLabeledTextField(String labelText, boolean makeVertical){
|
public void addLabeledTextField(String labelText, boolean makeVertical){
|
||||||
@ -113,8 +107,7 @@ public class aufg {
|
|||||||
this.contentPane.add(makePasswordField());
|
this.contentPane.add(makePasswordField());
|
||||||
}
|
}
|
||||||
public JPasswordField makePasswordField(){
|
public JPasswordField makePasswordField(){
|
||||||
JPasswordField passwordField = new JPasswordField(10);
|
return new JPasswordField(10);
|
||||||
return passwordField;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLabeledPasswordField(String label, boolean makeVertical){
|
public void addLabeledPasswordField(String label, boolean makeVertical){
|
||||||
@ -139,8 +132,7 @@ public class aufg {
|
|||||||
this.contentPane.add(makeTextArea(rows, cols));
|
this.contentPane.add(makeTextArea(rows, cols));
|
||||||
}
|
}
|
||||||
public JTextArea makeTextArea(int rows, int cols){
|
public JTextArea makeTextArea(int rows, int cols){
|
||||||
JTextArea textArea = new JTextArea(rows, cols);
|
return new JTextArea(rows, cols);
|
||||||
return textArea;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addImage(String link){
|
public void addImage(String link){
|
||||||
@ -170,4 +162,20 @@ public class aufg {
|
|||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user