Idea打Jar包并生成exe文件(二:实现计算器的Java代码)

本文介绍了如何使用IntelliJ IDEA(Idea)将一个简单的计算器Java程序打包成jar文件,并进一步转换为可执行的exe文件,详细阐述了整个过程和所需步骤。
摘要由CSDN通过智能技术生成
package com.codefish.javaapp.app;

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

public class Counter extends Frame
{
    //声明三个面板的布局
    GridLayout gl1,gl2,gl3;
    Panel p0,p1,p2,p3;
    JTextField tf1;
    TextField tf2;
    Button b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26;
    StringBuffer str;//显示屏所显示的字符串
    double x,y;//x和y都是运算数
    int z;//Z表示单击了那一个运算符.0表示"+",1表示"-",2表示"*",3表示"/"
    static double m;//记忆的数字
    public Counter()
    {
        gl1=new GridLayout(1,4,10,0);//实例化三个面板的布局
        gl2=new GridLayout(4,1,0,15);
        gl3=new GridLayout(4,5,10,15);
        tf1=new JTextField(27);//显示屏
        tf1.setHorizontalAlignment(JTextField.RIGHT);
        tf1.setEnabled(false);
        tf1.setText("0");
        tf2=new TextField(10);//显示记忆的索引值
        tf2.setEditable(false);
//实例化所有按钮、设置其前景色并注册监听器
        b0=new Button("Backspace");
        b0.setForeground(Color.red);
        b0.addActionListener(new Bt());
        b1=new Button("CE");
        b1.setForeground(Color.red);
        b1.addActionListener(new Bt());
        b2=new Button("C");
        b2.setForeground(Color.red);
        b2.addActionListener(new Bt());
        b3=new Button("MC");
        b3.setForeground(Color.red);
        b3.addActionListener(new Bt());
        b4=new Button("MR");
        b4.setForeground(Color.red);
        b4.addActionListener(new Bt());
        b5=new Button("MS");
        b5.setForeground(Color.red);
        b5.addActionListener(new Bt());
        b6=new Button("M+");
        b6.setForeground(Color.red);
        b6.addActionListener(new Bt());
        b7=new Button("7");
        b7.setForeground(Color.blue);
        b7.addActionListener(new Bt());
        b8=new Button("8");
        b8.setForeground(Color.blue);
        b8.addActionListener(new Bt());
        b9=new Button("9");
        b9.setForeground(Color.blue);
        b9.addActionListener(new Bt());
        b10=new Button("/");
        b10.setForeground(Color.red);
        b10.addActionListener(new Bt());
        b11=new Button("sqrt");
        b11.setForeground(Color.blue);
        b11.addActionListener(new Bt());
        b12=new Button("4");
        b12.setForeground(Color.blue);
        b12.addActionListener(new Bt());
        b13=new Button("5");
        b13.setForeground(Color.blue);
        b13.a
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值