为什么 panelFirst 上的边界不起作用?它只是在顶部显示所有内容,而不是按照我设置的顺序显示边界?单选按钮应显示在另一个下方,下一个按钮应显示在最右侧,但它不起作用?
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();
}
});
}
}