muguangyu
2015-11-22 06:41
采纳率: 85.7%
浏览 1.5k
已采纳

关于java图形设计(急求)

图片

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • muguangyu 2015-11-22 10:15
    已采纳
        JRadioButton rdbtnNewRadioButton_2 = new JRadioButton("Chinese");
        rdbtnNewRadioButton_2.setFont(new Font("宋体", Font.PLAIN, 22));
        buttonGroup_1.add(rdbtnNewRadioButton_2);
        rdbtnNewRadioButton_2.setBounds(282, 360, 177, 29);
        contentPane.add(rdbtnNewRadioButton_2);
    
        JRadioButton rdbtnNewRadioButton_3 = new JRadioButton("English");
        rdbtnNewRadioButton_3.setFont(new Font("宋体", Font.PLAIN, 22));
        buttonGroup_1.add(rdbtnNewRadioButton_3);
        rdbtnNewRadioButton_3.setBounds(282, 397, 177, 29);
        contentPane.add(rdbtnNewRadioButton_3);
    
    
        final ButtonGroup group1 = new ButtonGroup();
        group1.add(rdbtnNewRadioButton_2);
        group1.add(rdbtnNewRadioButton_3);
    
        class FooterActionListener implements ActionListener {
            private int n;
            public void actionPerformed(ActionEvent ev) {
                if(ev.getSource().equals(rdbtnNewRadioButton_2))
                       //Middle m1=new HeaderOfChinese();
                 if(ev.getSource().equals(rdbtnNewRadioButton_3))
                         n=2;
            }
            public int getN()
            {
                return n;
            }
          }
    
        ActionListener alisten1 = new FooterActionListener();
        /**
         * 为2个单选框添加事件
         */
        rdbtnNewRadioButton_2.addActionListener(alisten1);
        rdbtnNewRadioButton_3.addActionListener(alisten1);
    
    
    
    
    
    已采纳该答案
    打赏 评论
  • threenewbee 2015-11-22 07:08

    不知道你说的按钮信息是什么,你可以定义一个成员变量,每次按一个按钮,就设置它,这样它保存的就是最后一次按钮的信息了。

    打赏 评论
  • 君莫傲 2015-11-24 01:14

    JRadioButton rdbtnNewRadioButton_2 = new JRadioButton("Chinese");
    rdbtnNewRadioButton_2.setFont(new Font("宋体", Font.PLAIN, 22));
    buttonGroup_1.add(rdbtnNewRadioButton_2);
    rdbtnNewRadioButton_2.setBounds(282, 360, 177, 29);
    contentPane.add(rdbtnNewRadioButton_2);

    JRadioButton rdbtnNewRadioButton_3 = new JRadioButton("English");
    rdbtnNewRadioButton_3.setFont(new Font("宋体", Font.PLAIN, 22));
    buttonGroup_1.add(rdbtnNewRadioButton_3);
    rdbtnNewRadioButton_3.setBounds(282, 397, 177, 29);
    contentPane.add(rdbtnNewRadioButton_3);
    
    
    final ButtonGroup group1 = new ButtonGroup();
    group1.add(rdbtnNewRadioButton_2);
    group1.add(rdbtnNewRadioButton_3);
    
    class FooterActionListener implements ActionListener {
        private int n;
        public void actionPerformed(ActionEvent ev) {
            if(ev.getSource().equals(rdbtnNewRadioButton_2))
                   //Middle m1=new HeaderOfChinese();
             if(ev.getSource().equals(rdbtnNewRadioButton_3))
                     n=2;
        }
        public int getN()
        {
            return n;
        }
      }
    
    ActionListener alisten1 = new FooterActionListener();
    /**
     * 为2个单选框添加事件
     */
    rdbtnNewRadioButton_2.addActionListener(alisten1);
    rdbtnNewRadioButton_3.addActionListener(alisten1);
    
    打赏 评论

相关推荐 更多相似问题