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