Center swing buttons
From: Guillaume D. (azuriel75REMOVE-ME_at_free.fr)
Date: 07/25/04
- Previous message: ak: "Re: Double Buffering Frame not Applet Problem"
- Next in thread: Stewart Gordon: "Re: Center swing buttons"
- Reply: Stewart Gordon: "Re: Center swing buttons"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 25 Jul 2004 18:52:39 +0200
Why in this code, the Ok and Cancel Buttons are centered ?
I want them to be at the right side.
...
JPanel mainPanel = new JPanel();
mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
getContentPane().add(mainPanel, BorderLayout.CENTER);
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));
// Top panel
JPanel topPanel = new JPanel();
mainPanel.add(topPanel);
topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.LINE_AXIS));
JTree tree = new JTree();
JScrollPane treeView = new JScrollPane(tree);
topPanel.add(treeView);
JPanel rightPanel = new JPanel();
topPanel.add(rightPanel);
// Rigid area between two panels
mainPanel.add(Box.createRigidArea(new Dimension(0, 3)));
// Bottom buttons panel
JPanel bottomPanel = new JPanel();
mainPanel.add(bottomPanel);
bottomPanel.setLayout(new BoxLayout(bottomPanel,
BoxLayout.LINE_AXIS));
bottomPanel.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
// Cancel button
buttonCancel = new JButton("Cancel");
bottomPanel.add(buttonCancel);
// Rigid area between buttons
bottomPanel.add(Box.createRigidArea(new Dimension(2, 0)));
// Ok button
buttonOk = new JButton("Ok");
bottomPanel.add(buttonOk);
}
- Previous message: ak: "Re: Double Buffering Frame not Applet Problem"
- Next in thread: Stewart Gordon: "Re: Center swing buttons"
- Reply: Stewart Gordon: "Re: Center swing buttons"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]