Hi I'm having a problem in GridBagLayout.. I want my code to be same in the image below..
asdf.png
But my code output looks like this..
aa.png
And How can I set the color of box in checkbox to orange.
Please help.. Thanks
Here's my Code..
import java.awt.*; import java.applet.*; public class test extends Applet { Panel pane = new Panel(); Checkbox check; GridBagConstraints c = new GridBagConstraints(); public void init() { pane.setLayout(new GridBagLayout()); c.fill = GridBagConstraints.HORIZONTAL; c.ipadx = 15; check = new Checkbox("Value Meals"); c.gridx = 0; c.gridy = 0; pane.add(check, c); check = new Checkbox("Meal 1"); c.gridx = 1; c.gridy = 1; pane.add(check, c); check = new Checkbox("Meal 2"); c.gridx = 1; c.gridy = 2; pane.add(check, c); check = new Checkbox("Meal 3"); c.gridx = 2; c.gridy = 1; pane.add(check, c); check = new Checkbox("Meal 4"); c.gridx = 2; c.gridy = 2; pane.add(check, c); check = new Checkbox("Meal 5"); c.gridx = 3; c.gridy = 1; pane.add(check, c); check = new Checkbox("Meal 6"); c.gridx = 3; c.gridy = 2; pane.add(check, c); add(pane); setSize(400, 200); } }