Anfänger mit GirdBagLayout
-
Hallo ,
bin mit GridBagLayout nur angefangen und ich möchte ein Programm erstellen das folgende interface erstellen
http://imageshack.us/photo/my-images/101/60257008.png/
nun ich habe es so gemacht,import javax.swing.*; import java.awt.*; class Aufgabe1Blatt6 extends JFrame{ JFrame frame=new JFrame("Aufgabe1"); JButton button=new JButton("Button3"); JRadioButton radio1=new JRadioButton("Button1"); JRadioButton radio2=new JRadioButton("Button2"); JScrollPane scroll=new JScrollPane(); JList list ; ButtonGroup gruppe=new ButtonGroup(); Aufgabe1Blatt6(){ this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GridBagConstraints c=new GridBagConstraints(); JPanel panel=new JPanel(new GridBagLayout()); this.radio1.setBackground(Color.yellow); this.radio2.setBackground(Color.yellow); this.radio1.setSize(10,10); this.radio2.setSize(10, 10); this.gruppe.add(radio1); this.gruppe.add(radio2); c.gridx=0; c.gridy=0; c.fill=GridBagConstraints.HORIZONTAL; this.frame.add(panel); panel.add(radio1,c); c.insets=new Insets(2,0,0,0); c.gridy=1; panel.add(radio2,c); c.gridy=2; c.insets=new Insets(100,0,0,0); panel.add(button,c); c.gridx=1; c.gridy=0; c.fill=GridBagConstraints.VERTICAL; c.insets=new Insets(0,2,0,0); String[] listWerte={"Inhalt Nr.1","Inhalt Nr.2","Inhalt Nr.3","Inhalt Nr.4","Inhalt Nr.5","Inhalt Nr.6","Inhalt Nr.7" ,"Inhalt Nr.8","Inhalt Nr.9","Inhalt Nr.10"}; this.list=new JList(listWerte); this.scroll=new JScrollPane(this.list); panel.add(this.scroll,c); this.frame.setVisible(true); this.frame.pack(); } public static void main(String ...args){ // Schwarze Magie, Voodoo, ... SwingUtilities.invokeLater(new Runnable() { public void run() { Aufgabe1Blatt6 mw = new Aufgabe1Blatt6(); } }); } }und so sieht es aus bei mir,und leider habe ich so lange versuch,aber w könnte es nicht erstellen so das es wie im Foto aussieht und auch dass die beide radiobuttons immer obenlinks stehen,
ich habe es mitpanel.add(radio1,BorderLayout.NorthWest)probiert aber es hat nie geklappt da NorthWest nicht definiert, entweder West oder North,
Bitte kann jemand mir helfen Bitte:(:(??
Danke sehr.