⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jcomponentexam.java

📁 java学习课件
💻 JAVA
字号:
package ch7;
import java.awt.*;
import javax.swing.*;
public class JcomponentExam extends JFrame
{
  JTextField name=new JTextField(10);
  JPasswordField pass=new JPasswordField();
  JButton exit,ok;
  public JcomponentExam()
  {
    Container pane=this.getContentPane();
    pane.setLayout(new GridLayout(0,2));
    Icon i1=new ImageIcon("./people.gif");
    Icon i2=new ImageIcon("./lock.gif");
    Icon i3=new ImageIcon("./exit.gif");
    Icon i4=new ImageIcon("./mouse.gif");
    pane.add(new JLabel("用户名",i1,0));
    pane.add(name);
    pane.add(new JLabel("口令",i2,0));
    pane.add(pass);
    exit=new JButton("退出",i3);
    ok=new JButton("登录",i4);
    pane.add(exit);
    pane.add(ok);
    this.setTitle("用户登录");  //设置框架窗口标题
  	this.setBounds(100,100,300,150); //设置框架窗口的显示位置及大小
    this.setVisible(true);  //设置框架窗口是可见的
    this.setDefaultCloseOperation(3); //单击关闭按钮后,推出程序
  }
  public static void main(String args[])
  {
  	new JcomponentExam(); //创建对象显示用户登录界面
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -