zoukankan      html  css  js  c++  java
  • java combobox 多选框

    简介

    简单

    code

    package calcu;
    
    import java.awt.*;
    import javax.swing.*;
    
    public class ComboBoxFrame extends JFrame {
        private JComboBox<String> faceCombo;
        private JLabel label;
        private static final int DEFAULT_SIZE = 24;
    
        public static void main(String[] args) {
            ComboBoxFrame t = new ComboBoxFrame();
            t.setTitle("ImageTest");
            t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            t.setVisible(true);
        }
    
        public ComboBoxFrame() {
            label = new JLabel("The qucik brown fox jumps over the lazy dog.");
            label.setFont(new Font("Serif", Font.PLAIN, DEFAULT_SIZE));
    
            add(label, BorderLayout.CENTER);
    
            // make a combo box and add face names
    
            faceCombo = new JComboBox<>();
            faceCombo.addItem("Serif");
            faceCombo.addItem("SansSerif");
            faceCombo.addItem("Monospaced");
            faceCombo.addItem("Dialog");
            faceCombo.addItem("DialogInput");
    
            // the combo box listener changes the label font to the selected face name
    
            faceCombo.addActionListener(event -> label
                    .setFont(new Font(faceCombo.getItemAt(faceCombo.getSelectedIndex()), Font.PLAIN, DEFAULT_SIZE)));
    
            // add combo box to a panel at the frame's southern border
    
            JPanel comboPanel = new JPanel();
            comboPanel.add(faceCombo);
            add(comboPanel, BorderLayout.SOUTH);
            pack();
        }
    
    }
    
    Hope is a good thing,maybe the best of things,and no good thing ever dies.----------- Andy Dufresne
  • 相关阅读:
    DVWA SQL Injection High
    DVWA SQL Injection Medium
    Sagemath在ctf密码学中的使用
    Python杂记
    Elgamal&RSA小结
    攻防世界-密码学-onetimepad
    攻防世界-密码学-sleeping-guard
    攻防世界-密码学-streamgame1
    GACTF2020密码学部分详解
    攻防世界-密码学-xor_game
  • 原文地址:https://www.cnblogs.com/eat-too-much/p/13930298.html
Copyright © 2011-2022 走看看