msgframe.java

来自「《JAVA网络编程实例》源代码」· Java 代码 · 共 45 行

JAVA
45
字号
import java.awt.*;import java.awt.event.*;/** * File:        msgFrame.java  用户消息提示框。 */public class msgFrame extends Frame {  Button button1 = new Button();  TextArea textArea1 = new TextArea();  public msgFrame(String msg) {    try {      jbInit();      textArea1.setText(msg);      this.setSize(260,200);    }    catch(Exception e) {      e.printStackTrace();    }  }  private void jbInit() throws Exception {    button1.setLabel("确认");    button1.setBounds(new Rectangle(31, 129, 159, 19));    button1.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        button1_actionPerformed(e);      }    });    this.setLayout(null);    textArea1.setColumns(9);    textArea1.setText("textArea1");    textArea1.setBounds(new Rectangle(21, 19, 180, 97));    this.add(button1, null);    this.add(textArea1, null);  }  void button1_actionPerformed(ActionEvent e) {    //当用户点击确认后隐藏该窗口。    this.hide();  }}

⌨️ 快捷键说明

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