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

📄 frame1.java

📁 jbuilder2005
💻 JAVA
字号:
package calculator;

import java.awt.*;
import javax.swing.*;

public class Frame1
    extends JFrame {
  JPanel contentPane;
  BorderLayout borderLayout1 = new BorderLayout();
  GridLayout gridLayout1 = new GridLayout(4,4,2,2);  //4行,4列,间距
  Label label1 = new Label();
  Panel panel1 = new Panel();
  Button button1 = new Button();
  Button button2 = new Button();
  Button button3 = new Button();
  Button button4 = new Button();
  Button button5 = new Button();
  Button button6 = new Button();
  Button button7 = new Button();
  Button button8 = new Button();
  Button button9 = new Button();
  Button button10 = new Button();
  Button button11 = new Button();
  Button button12 = new Button();
  Button button13 = new Button();
  Button button14 = new Button();
  Button button15 = new Button();
  Button button16 = new Button();

  public Frame1() {
    try {
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      jbInit();
    }
    catch (Exception exception) {
      exception.printStackTrace();
    }
  }

  /**
   * Component initialization.
   *
   * @throws java.lang.Exception
   */
  private void jbInit() throws Exception {
    contentPane = (JPanel) getContentPane();
    contentPane.setLayout(borderLayout1);
    setSize(new Dimension(200,160));
    setTitle("简易计算器");
    contentPane.add(label1, java.awt.BorderLayout.NORTH);
    contentPane.add(panel1, java.awt.BorderLayout.CENTER);
    label1.setAlignment(Label.RIGHT);
    label1.setBackground(Color.white);
    label1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
    label1.setText("0.");
    button1.setLabel("7");
    button2.setLabel("8");
    button3.setLabel("9");
    button4.setLabel("+");
    button5.setLabel("4");
    button6.setLabel("5");
    button7.setLabel("6");
    button8.setLabel("-");
    button9.setLabel("1");
    button10.setLabel("2");
    button11.setLabel("3");
    button12.setLabel("0");
    button13.setLabel(".");
    button14.setLabel("*");
    button15.setLabel("=");
    button16.setLabel("/");
    panel1.setLayout(gridLayout1);
    panel1.add(button1);
    panel1.add(button2);
    panel1.add(button3);
    panel1.add(button4);
    panel1.add(button5);
    panel1.add(button6);
    panel1.add(button7);
    panel1.add(button8);
    panel1.add(button9);
    panel1.add(button10);
    panel1.add(button11);
    panel1.add(button14);
    panel1.add(button12);
    panel1.add(button13);
    panel1.add(button15);
    panel1.add(button16);
  }
}

⌨️ 快捷键说明

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