• Swing类


    考试系统:
    1.登录功能 用户名和密码存在哪里?文件
    2.考试功能 考试题目和答案存在哪?文件
    3.展示功能 GUI Graphical User Interface(图形用户接口)
    #GUI
    Java集合 String
    I/O
    文件

    C------>桌面应用程序
    C/S---->Client Server 客户端/服务端 QQ
    *B/S---->Browser Server 浏览器/服务器 淘宝

    GUI
    Graphical User Interface(图形用户接口)
    就是采用图形的方式,进行操作页面的展示

    画图======两个实现方式
    AWT 抽象窗体工具包(Abstract Window Toolkit)
    Swing 摇摆,悬挂的意思

    窗口======几块大的内容组合在一起
    窗口(几块大的内容组合在一起)---->窗体
    AWT----->Frame
    Swing------>JFrame
    面板 panel JPanel
    菜单条 JMenuBar:菜单 菜单项
    组件(放面板里面):标签、文本框、密码框、按钮、单选框、复选框、文本域、滚动条。
    Button JButton(按钮)
    Label JLabel(组件)
    TextField JTextField(单选文本框)
    TextAre JTextArea(文本域)
    JPasswordField(密码)
    JCheckBox(复选框)
    JRadioButton(单选按钮)
    JMenuBar JMenu JMenultem

    *事件 (里面有监听器)
    ActionListener 动作/响应事件
    KeyListener 键盘事件
    MouseListener 鼠标事件
    ComponentListener Item Window 等

    package testgui;
    
    import javax.swing.*;
    
    public class TestGUI {
        public static void main(String[] args) {
            //frame  最大的窗体  管理方式边界式  中 东 西 南  北    BorderLayout
            //JMenuBar  菜单条  上面  frame.setJMenuBar(bar)
            //Panel  面板  可以有很多个  管理方式流式 居中      FlowLayout
            //组件
            //frame.setLayOut(new FlowLayout());  frame.setLayout(null);
    
            //1.先创建一个窗体  设置窗体的title
            JFrame  frame=new JFrame("这是我的第一个窗体");
            //创建一个面板
            JPanel panel=new JPanel();
    
            //创建标签
            JLabel userLabel=new JLabel("账户:");
            JLabel passLabel=new JLabel("密码:");
            //创建一个文本框
            JTextField text=new JTextField(20);
            //密码框
            JPasswordField pass=new JPasswordField(20);
            //创建一个按钮对象  button.setText("");
            JButton button=new JButton("登录");
    
            //创建复选框
            JCheckBox box1=new JCheckBox("抽烟");
            JCheckBox box2=new JCheckBox("喝酒");
            JCheckBox box3=new JCheckBox("烫头");
    
            //创建单选按钮
            JRadioButton r1=new JRadioButton("男");
            JRadioButton r2=new JRadioButton("女");
            //将两个单选按钮添加在一个组里面
            ButtonGroup group=new ButtonGroup();//组本身不是组件
            group.add(r1);
            group.add(r2);
    
            //创建文本域
            JTextArea area=new JTextArea(5,20);
            //滚动条
            JScrollPane pane=new JScrollPane(area);
    
            //菜单条   JMenuBar----Panel
            //菜单   JMenu
            //菜单项   JMenuItem
            JMenuBar bar=new JMenuBar();
            JMenu menu=new JMenu("File");
            JMenuItem newItem=new JMenuItem("New");
    
            menu.add(newItem);
            bar.add(menu);
    
    
            //将按钮添加在窗体内
            panel.add(userLabel);
            panel.add(text);
            panel.add(passLabel);
            panel.add(pass);
            panel.add(button);
            panel.add(box1);
            panel.add(box2);
            panel.add(box3);
            panel.add(r1);
            panel.add(r2);
            panel.add(pane);
    
            frame.setJMenuBar(bar);
            frame.add(panel);
    
            //设置不可以拖拽大学
            //frame.setResizable(false);
            //设置窗体出现时的位置和自身的宽高
            frame.setBounds(500,250,300,150);
            //2.设置窗体的属性状态显示
            frame.setVisible(true);
            //设置点击关闭按钮  窗体执行完毕
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83

    在这里插入图片描述

  • 相关阅读:
    [黑马程序员Pandas教程]——分组与分箱
    10000字!图解机器学习特征工程
    基于ssm的图书商城
    【Linux】深刻理解进程概念、进程状态、进程常用指令和系统调用
    鸿蒙入门05-真机运行“遥遥领先”
    A-level商务例题解析及练习market segmentatio
    html- a标签包裹img标签, 点击图片无法跳转问题记录及解决方法
    2022春季《人工智能》EOJ代码个人汇总(A.八数码问题 到 J.迷宫寻找)
    价格监测的目标
    自定义MVC
  • 原文地址:https://blog.csdn.net/m0_53222768/article/details/125596921