zoukankan      html  css  js  c++  java
  • java checkbox

    简介

    checkbox

    code

    /*
     * @Author: your name
     * @Date: 2020-11-04 09:44:08
     * @LastEditTime: 2020-11-04 09:53:07
     * @LastEditors: your name
     * @Description: In User Settings Edit
     * @FilePath: /java/calcu/CheckBoxTest.java
     */
    package calcu;
    
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    
    
    public class CheckBoxTest extends JFrame {
        private JLabel label;
        private JCheckBox bold;
        private JCheckBox italic;
        private static final int FONTSIZE = 24;
        public static void main(String[] args){
            CheckBoxTest t = new CheckBoxTest();
            t.setTitle("ImageTest");
            t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            t.setVisible(true);
        }
        public CheckBoxTest() {
            // add the sample text label
    
            label = new JLabel("The quick brown fox jumps over the lazy dog.");
            label.setFont(new Font("Serif", Font.BOLD, FONTSIZE));
            add(label, BorderLayout.CENTER);
    
            // this listener sets the font attribute of
            // the label to the checkbox state
    
            ActionListener listener = event -> {
                int mode = 0;
                if (bold.isSelected())
                    mode += Font.BOLD;
                if (italic.isSelected())
                    mode += Font.ITALIC;
                label.setFont(new Font("Serif", mode, FONTSIZE));
            };
            // add the check boxes
            JPanel buttonPanel = new JPanel();
    
            bold = new JCheckBox("Bold");
            bold.addActionListener(listener);
            bold.setSelected(true);
            buttonPanel.add(bold);
    
            italic = new JCheckBox("Italic");
            italic.addActionListener(listener);
    
            buttonPanel.add(italic);
    
            add(buttonPanel, BorderLayout.SOUTH);
            pack();
        }
    }
    
    

    Q&A

    简单

    Hope is a good thing,maybe the best of things,and no good thing ever dies.----------- Andy Dufresne
  • 相关阅读:
    网络流 KM dinic
    网络流 增广路 回退
    树链剖分
    线段树区间更新 lazy
    全排列
    各种蕴含算法思想的DP
    各种蕴含算法思想的DP
    Strassen矩阵乘法之思考
    [0,x)的随机数
    hdu1331 按着题目的公式直接写
  • 原文地址:https://www.cnblogs.com/eat-too-much/p/13924394.html
Copyright © 2011-2022 走看看