Tuesday, 6 August 2013

Why are the bounds not working on this GUI

Why are the bounds not working on this GUI

Why are the bounds on the panelFirst not working? It just displays
everything at the top and it does not display the bounds in the order I
have set them? The radio buttons should display in one under the other and
the next button should display on the far right but it is not working?
public MyWizard() {
panelContainer.setLayout(c1);
panelFirst.add(btNext);
panelSecond.add(btNextTwo);
panelFirst.setBackground(Color.BLUE);
panelSecond.setBackground(Color.RED);
panelThird.setBackground(Color.GREEN);
panelContainer.add(panelFirst, "1");
panelContainer.add(panelSecond,"2");
panelContainer.add(panelThird,"3");
c1.show(panelContainer, "1");
btNext.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
c1.show(panelContainer,"2");
}
});
btNextTwo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
c1.show(panelContainer,"3");
}
});
RadioButtons();
Button();
frame.add(panelContainer);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
frame.setSize(600,360);
frame.setVisible(true);
}
public void RadioButtons() {
btLdap = new JRadioButton ("Ldap");
btLdap.setBounds(60,85,100,20);
panelFirst.add(btLdap);
btKerbegos = new JRadioButton ("Kerbegos");
btKerbegos.setBounds(60,115,100,20);
panelFirst.add(btKerbegos);
btSpnego =new JRadioButton("Spnego");
btSpnego.setBounds(60,145,100,20);
panelFirst.add(btSpnego);
btSaml2 = new JRadioButton("Saml2");
btSaml2.setBounds(60,175,100,20);
panelFirst.add(btSaml2);
}
public void Button() {
btNext.setBounds(400,260,100,20);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new MyWizard();
}
});
}
}

No comments:

Post a Comment