skæve checkboxes
Hvorfor står disse checkboxe skævt iforhold til hianden.er det muligt at lave checkboxgrupper med swing
Kode
import java.awt.*;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.*;
import java.awt.Checkbox;
import java.awt.CheckboxGroup;
public class GUI extends javax.swing.JFrame {
private GridBagLayout mainMenu;
private GridBagConstraints con;
private JPanel panel1,panel2;
private Checkbox c1,c2,c3,c4, c5, c6,c7,c8,c9,c10,c11;
private CheckboxGroup cbg;
private JButton b;
public GUI() {
setSize(1000, 800);
mainMenu = new GridBagLayout();
getContentPane().setLayout(mainMenu);
panel1 = new JPanel();
panel1.setLayout( new GridBagLayout());
c1 = new Checkbox(\"e\");
con = createGBC(0,0,1,1);
panel1.add(c1, con);
c2 = new Checkbox(\"f\");
con = createGBC(0,1,1,1);
panel1.add(c2, con);
c3 = new Checkbox(\"f#\");
con = createGBC(0,2,1,1);
panel1.add(c3, con);
c4 = new Checkbox(\"g\");
con = createGBC(0,3,1,1);
panel1.add(c4, con);
c5 = new Checkbox(\"g\");
con = createGBC(1,0,1,1);
panel1.add(c5, con);
c6 = new Checkbox(\"g\");
con = createGBC(1,1,1,1);
panel1.add(c6, con);
c7 = new Checkbox(\"g\");
con = createGBC(1,2,1,1);
panel1.add(c7, con);
panel1.setBorder( new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), \"Søg\" ));
con = createGBC(0,0,1,1);
getContentPane().add( panel1,con );
}
private GridBagConstraints createGBC(int x, int y, int width, int height)
{
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx=x;
gbc.gridy=y;
gbc.gridwidth=width;
gbc.gridheight= height;
gbc.insets= new Insets(0,0,0,0);
return gbc;
}
private void add(JComponent c, GridBagConstraints gbc)
{
//mainMenu.setConstraints(c, gbc);
getContentPane().add(c);
}
}
