hi,
how to set the width of a JPanel with a GridLayout as the layout manager.
thanks.
how to set the width of a JPanel with a GridLayout as the layout manager.
thanks.
public class MainForm extends JFrame {
//these classes are extended from the JPanel
//and will be placed at the frame
private Game game;
private UserPanel usrPanel1, usrPanel2;
private DicePanel dicePanel;
private TidePanel tidePanel;
public MainForm() {
/*instantiation of the panels
.....
*/
//right panel container
JPanel rightPanel = new JPanel(new GridLayout(4, 1, 10, 10));
rightPanel.add(usrPanel1);
rightPanel.add(usrPanel2);
rightPanel.add(dicePanel);
rightPanel.add(tidePanel);
//main panel for the frame
JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.add(bjackPanel, "North");
mainPanel.add(game, "Center");
mainPanel.add(rightPanel, "East");
//add mainPanel to the frame
add(mainPanel);
//set some property of the frame
setSize(935, 700);
setResizable(false);
setLocationRelativeTo(null);
setVisible(true);
}
}
Comment