Hi, how can I make a button place side by side. I used a gridBagLayout to design the layout.The problem is that the button place too far from each other. I have tried to choose the CENTER as anchor but this makes the button overlapping. If I used WEST and EAST, the button placed too far from each other.
e.g. SAVE ---------- NEW PATTERN instead of SAVE NEW_PATTERN.
JButton bSave = new JButton("SAVE");
JButton bPattern = new JButton("NEW_PATTERN");
con = new GridBagConstraints();
con.anchor=GridBagConstraints.WEST;
con.gridy = 3; con.gridx = 0;
con.gridwidth = 1; con.gridheight = 1;
con.insets= new Insets(2,5,2,2);
m.setConstraints(bSave, con);
c.add(bSave);
con.weightx=1;
con.gridy=3; con.gridx=0;
con.anchor=GridBagConstraints.EAST;
m.setConstraints(bPattern,con);
c.add(bPattern);