下面的应用程序中有一个组,组内有4个单选按钮,请在画线处填入正确的语句使程序能正确运行。 import javax.swing.*; public class OneTeam extends JFrame { JRadioB

admin2010-02-22  39

问题 下面的应用程序中有一个组,组内有4个单选按钮,请在画线处填入正确的语句使程序能正确运行。
    import javax.swing.*;
   public class OneTeam extends JFrame
   {
      JRadioButton[] teams = new JRadioButton[3];
      public OneTeam()
      {
          super("One Team");
          setSize (140,160);
          setDefaultCloseOperation(JFrame.EXIT ON CLOSE
          JPanel pane = new JPanel();
          teams[0] = new JRadioButton("red choose");
          teams[l] = new JRadioButton("blue choose");
          teams[2] = new JRadioButton("green choose");
         【  】;
          for ( int i = 0;i < teams.length;i++)
          {
              group.add(teams);
              pane.add(teams);
              }
              setContentPane(pane);
          }
      public static void main(String arguments[]
      {
          OneTeam ot= new OneTeam();
          ot.show();
      }

选项

答案ButtonGroup group=new ButtonGroup()

解析 本题考查Swing常用组件单选按钮组运用的基本知识。阅读程序和由显示结果可以得出, group是一个组,而且是单选按钮组。而程序里没有group单选按钮组的创建语句,所以在空行里应该创建1个单选按钮组给group。
转载请注明原文地址:https://kaotiyun.com/show/lanp777K
0

最新回复(0)