zoukankan      html  css  js  c++  java
  • 自考 课后题 第六章6

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Exec65 extends JFrame implements ItemListener{
    
        JComboBox box;
        JTextField text;
        static String[] lessons = {"语文","数学","化学","物理"};
        public static void main(String[] args) {
            new Exec65();
    
        }
        public Exec65(){
            this.setTitle("Test");
            this.setSize(500,500);
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.setLocationRelativeTo(null);
            
            
            
            box = new JComboBox(lessons);
            box.setEditable(true);
            box.addItemListener(this);
            text = new JTextField(10);
            
            add(box,BorderLayout.NORTH);
            add(text,BorderLayout.CENTER);
            
            this.setVisible(true);
            pack();
        }
        @Override
        public void itemStateChanged(ItemEvent e) {
            text.setText(((JComboBox)(e.getSource())).getSelectedItem().toString());
            
        }
    
    }
  • 相关阅读:
    jq insertBefore 的返回值
    微信公众号-定位之地址逆解析&导航
    微信JS-SDK
    Vue
    ES6-函数的扩展
    ES6-数组的扩展
    JSP
    JS
    HTML+CSS
    jdbc操作数据库
  • 原文地址:https://www.cnblogs.com/qqjue/p/2627637.html
Copyright © 2011-2022 走看看