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

📄 frame1.java~11~

📁 这是一个MyExprText程序,,是用JAVA开发的,提大家学习
💻 JAVA~11~
字号:
package javabook.lecture2.myexprtest;import java.awt.*;import java.awt.event.*;import javax.swing.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class Frame1 extends JFrame {  JPanel contentPane;  JLabel statusBar = new JLabel();  FlowLayout flowLayout1 = new FlowLayout();  Label label1 = new Label();  TextField textField1 = new TextField();  TextField textField2 = new TextField();  Button button1 = new Button();  TextArea textArea1 = new TextArea();  //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();    contentPane.setLayout(flowLayout1);    this.setSize(new Dimension(400, 250));    this.setTitle("我的计算器");    statusBar.setText(" ");    label1.setText("请输入两个整型数据");    textField1.setColumns(7);    textField1.setText("");    textField2.setColumns(7);    textField2.setText("");    button1.setLabel("确认");    button1.addActionListener(new Frame1_button1_actionAdapter(this));    textArea1.setColumns(50);    textArea1.setEditable(false);    textArea1.setEnabled(true);    textArea1.setText("");    textArea1.setVisible(true);    contentPane.setToolTipText("");    contentPane.setVerifyInputWhenFocusTarget(true);    contentPane.add(statusBar, null);    contentPane.add(label1, null);    contentPane.add(textField1, null);    contentPane.add(textField2, null);    contentPane.add(button1, null);    contentPane.add(textArea1, 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);    }  }  void button1_actionPerformed(ActionEvent e) {    int a = Integer.parseInt(textField1.getText());    int b = Integer.parseInt(textField2.getText());     textArea1.setText("");     textArea1.append(a + "+" + b + "=" + (a+b) + "\n");  }}class Frame1_button1_actionAdapter implements java.awt.event.ActionListener {  Frame1 adaptee;  Frame1_button1_actionAdapter(Frame1 adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.button1_actionPerformed(e);  }}

⌨️ 快捷键说明

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