frame1.java

来自「这是关于JAVA的图形用户界面起步的一个小程序和源码」· Java 代码 · 共 59 行

JAVA
59
字号
package wordgui;import java.awt.*;import java.awt.event.*;import javax.swing.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class Frame1 extends JFrame {  JPanel contentPane;  JLabel jLabel1 = new JLabel();  JTextField jTextField1 = new JTextField();  JPasswordField jPasswordField1 = new JPasswordField();  JTextArea jTextArea1 = new JTextArea();  //Construct the frame  public Frame1() {    enableEvents(AWTEvent.WINDOW_EVENT_MASK);    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  //Component initialization  private void jbInit() throws Exception  {    contentPane = (JPanel) this.getContentPane();    jLabel1.setText("标签栏");    jLabel1.setBounds(new Rectangle(35, 37, 94, 23));    contentPane.setLayout(null);    this.setSize(new Dimension(282, 191));    this.setTitle("文本输入组件");    jTextField1.setText("文本域");    jTextField1.setBounds(new Rectangle(35, 76, 98, 23));    jPasswordField1.setText("密码域");    jPasswordField1.setBounds(new Rectangle(35, 115, 99, 23));    jTextArea1.setText("文本区");    jTextArea1.setBounds(new Rectangle(157, 34, 98, 103));    contentPane.add(jTextField1, null);    contentPane.add(jPasswordField1, null);    contentPane.add(jTextArea1, null);    contentPane.add(jLabel1, null);  }  //Overridden so we can exit when window is closed  protected void processWindowEvent(WindowEvent e) {    super.processWindowEvent(e);    if (e.getID() == WindowEvent.WINDOW_CLOSING) {      System.exit(0);    }  }}

⌨️ 快捷键说明

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