我正在将'Java Swing'代码从'Java Visual Cafe'JDK1.2迁移到'Eclipse SDK6'。在Visual Cafe中它的代码是这样的:
public Sample extends JPanel(){
.....
package com.symantec.itools.javax.swing.JButtonGroupPanel bgAcc = new com.symantec.itools.javax.swing.JButtonGroupPanel();
....
bgAcc.setBorder(tbAcc); //tbAcc is titledBorder component type
..
bgAcc.setBounds(0,108,400,76);
...
bgAcc.add(bgLb); // bgLb is JLabel component type
..
bgAcc.add(button1, new GridBagConstraints(...));
..
}
有人可以建议如何在Eclipse SDK6中替换此代码吗?我无法在'Swing'中找到'ButtonGroup'的这些方法。
答案 0 :(得分:3)
我对JButtonGroupPanel
课程并不熟悉,但您使用的这些方法也可以在常规JPanel
上使用。
ButtonGroup
在Swing中是一个完全不同的概念,然后是JPanel
。例如,ButtonGroup
用于对一组JRadioButtons
进行分组,并确保当时只能选择该组中的一个单选按钮。但ButtonGroup
不是JComponent
也不是Container
,所以当然你不会找到类似setBorder
的方法。
旁注:请勿移植setBounds
次来电。使用合适的LayoutManager
代替