hallo Leute,
wie im Bild steht möchte ich Buttons schmaler haben. Welche Layout würdet ihr mir empfehlen?
wo mache ich fehler?
wie im Bild steht möchte ich Buttons schmaler haben. Welche Layout würdet ihr mir empfehlen?
wo mache ich fehler?
Java:
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.LayoutManager;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JTree;
public class DritteAufgabeFrame extends JFrame{
public DritteAufgabeFrame(){
setTitle("Meine dritte Aufgabe");
setSize(500,600);
setLocationByPlatform(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLayout(new BorderLayout());
JPanel oberePanel = new JPanel(new GridLayout(1,3));
oberePanel.add(new JTextField());
String listData[] = {"Apfel", "Birne", "orange"};
JComboBox comboBox = new JComboBox(listData);
oberePanel.add(comboBox);
oberePanel.add(new JButton("Button1"));
add(oberePanel, BorderLayout.PAGE_START);
JTree tree = new JTree();
add(tree, BorderLayout.LINE_START);
JPanel unterePanel = new JPanel(new GridLayout(3,1));
String liste[] = {"eins", "zwei", "drei"};
JList myList = new JList(liste);
unterePanel.add(myList);
JPanel buttonPanel = new JPanel(new GridLayout(1,3));
buttonPanel.add(new JButton("Button1"));
buttonPanel.add(new JButton("Button2"));
buttonPanel.add(new JButton("Button3"));
unterePanel.add(buttonPanel);
unterePanel.add(new JEditorPane());
add(unterePanel, BorderLayout.CENTER);
}
public static void main(String[] args) {
DritteAufgabeFrame frame = new DritteAufgabeFrame();
frame.setVisible(true);
}
}