1. JGoodies FormLayout question place buttons at center coderanch.comI am trying to learn JGoodies FormLayout. I started working with the Default FormBuilder and I am having trouble aligning 2 buttons at the centre of the panel. I need to do this: User Name Text Field Password Text Field .. .. .. Create Cancel The create and cancel buttons should appear bang on the centre of the panel. The buttons ... |
2. how to center this button 1 coderanch.comhow to center button 1 please? what code will i add. import java.awt.*; import javax.swing.*; class Test{ public static void main(String args[]){ new width(); } static class width extends JFrame{ width(){ super("Frame"); JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); JButton button1 = new JButton("button 1"); JButton button2 = new JButton("button 2"); JButton button3 = new JButton("button 3"); ... |
3. buttons won't center java-forums.orgpublic TwoButtonFrame(String titleString, String labelString, String leftButtonString, String rightButtonString) { setTitle(titleString); // init left button leftButton = new JButton(leftButtonString); leftButton.addActionListener(this); // init right button rightButton = new JButton(rightButtonString); rightButton.addActionListener(this); // add frame components using a GridBagLayout with constraints Container container = getContentPane(); container.setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.insets = new Insets(5, 5, 5, 5); constraints.gridx = 0; constraints.gridy = ... |