从com.symantec.itools.javax.swing包中替换ButtonGroupPanel

时间:2012-08-23 02:49:40

标签: java swing layout buttongroup null-layout-manager

我正在将'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'的这些方法。

1 个答案:

答案 0 :(得分:3)

我对JButtonGroupPanel课程并不熟悉,但您使用的这些方法也可以在常规JPanel上使用。

ButtonGroup在Swing中是一个完全不同的概念,然后是JPanel。例如,ButtonGroup用于对一组JRadioButtons进行分组,并确保当时只能选择该组中的一个单选按钮。但ButtonGroup不是JComponent也不是Container,所以当然你不会找到类似setBorder的方法。

旁注:请勿移植setBounds次来电。使用合适的LayoutManager代替