zoukankan      html  css  js  c++  java
  • e768. 创建单选按钮

    // Create an action for each radio button
        Action action1 = new AbstractAction("RadioButton Label1") {
            // This method is called whenever the radio button is pressed,
            // even if it is already selected; this method is not called
            // if the radio button was selected programmatically
            public void actionPerformed(ActionEvent evt) {
                // Perform action
            }
        };
        Action action2 = new AbstractAction("RadioButton Label2") {
            // See above
            public void actionPerformed(ActionEvent evt) {
                // Perform action
            }
        };
        
        // Create the radio buttons using the actions
        JRadioButton b1 = new JRadioButton(action1);
        JRadioButton b2 = new JRadioButton(action2);
        
        // Associate the two buttons with a button group
        ButtonGroup group = new ButtonGroup();
        group.add(b1);
        group.add(b2);
        
        // Neither radio button is selected; to select a radio button,
        // see e769 在按钮组中选择一个单选按钮
    
    
    Related Examples
  • 相关阅读:
    HTML_表单
    jabc_DAO
    JDBC 加钱减钱
    JDBC 连接池
    JDBC
    视图序列索引
    【Java8】 lambda 特性讲解
    IntelliJ IDEA 常用快捷键
    Java IO 之 装饰模式
    Java IO 讲解
  • 原文地址:https://www.cnblogs.com/borter/p/9596207.html
Copyright © 2011-2022 走看看