zoukankan      html  css  js  c++  java
  • java radioButton

    简介

    简单

    code

    
    /*
     * @Author: your name
     * @Date: 2020-11-04 10:19:14
     * @LastEditTime: 2020-11-04 10:28:50
     * @LastEditors: Please set LastEditors
     * @Description: In User Settings Edit
     * @FilePath: /java/calcu/RadioButtonFrame.java
     */
    
    package calcu;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    
    public class RadioButtonFrame extends JFrame {
        private JPanel buttonPanel;
        private ButtonGroup group;
        private JLabel label;
        private static final int DEFAULT_SIZE = 36;
    
        public static void main(String[] args) {
            RadioButtonFrame t = new RadioButtonFrame();
            t.setTitle("ImageTest");
            t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            t.setVisible(true);
        }
    
        public RadioButtonFrame() {
            label = new JLabel("The quick brown fox jumps over the lazy dog.");
            label.setFont(new Font("Serif", Font.PLAIN, DEFAULT_SIZE));
            add(label, BorderLayout.CENTER);
    
            // add the radio buttons
            buttonPanel = new JPanel();
            group = new ButtonGroup();
    
            addRadioButton("Small", 8);
            addRadioButton("Medium", 12);
            addRadioButton("Large", 18);
            addRadioButton("Extra large", 36);
    
            add(buttonPanel, BorderLayout.SOUTH);
            pack();
        }
    
        public void addRadioButton(String name, int size) {
            boolean selected = size == DEFAULT_SIZE;
            JRadioButton button = new JRadioButton(name, selected);
            group.add(button);
            buttonPanel.add(button);
    
            // this listener sets the label font size
            ActionListener listener = event -> label.setFont(new Font("Serif", Font.PLAIN, size));
    
            button.addActionListener(listener);
        }
    }
    
    Hope is a good thing,maybe the best of things,and no good thing ever dies.----------- Andy Dufresne
  • 相关阅读:
    关联接口,依赖接口的用法
    通过requests发送不同请求格式的数据
    requests请求数据参数化配置
    requests模块中通用的请求方法,即requests.request
    预期方向需要动态调整
    红枣大幅低开高开
    大涨大跌判断风向
    开盘大幅拉升回落
    红枣变盘之前的预测
    开盘情况要稳定才能进,不看看一根线
  • 原文地址:https://www.cnblogs.com/eat-too-much/p/13924596.html
Copyright © 2011-2022 走看看