代码如下

import java.awt.Color;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField; class myWindows extends JFrame implements ActionListener
{
private static final long serialVersionUID = 1L;
boolean tag=true;
boolean signal=true;
JTextField text1;
public myWindows(int w,int h)
{
setTitle("计算器程序");
this.setBounds(100,100,350,300);
Container con = getContentPane();
con.setLayout(new GridLayout(3,1));
JPanel p1 = new JPanel();
p1.setLayout(new GridLayout(2,1));
text1 = new JTextField(150);
text1.setHorizontalAlignment(text1.RIGHT);
text1.setText("0.");
JPanel p1_1 = new JPanel();
p1_1.setLayout(new GridLayout(1,4));
JButton btn_BackSpace = new JButton("BackSpace");
btn_BackSpace.setForeground(Color.red);
btn_BackSpace.addActionListener(this);
JButton btn_CE = new JButton("CE");
btn_CE.setForeground(Color.red);
JButton btn_C = new JButton("C");
btn_C.setForeground(Color.red);
btn_C.addActionListener(this);
p1.add(text1);
p1_1.add(new JLabel());
p1_1.add(btn_BackSpace);
p1_1.add(btn_CE);
p1_1.add(btn_C);
p1.add(p1_1); JPanel p2 = new JPanel();
p2.setLayout(new GridLayout(2,1));
JPanel p2_1 = new JPanel();
p2_1.setLayout(new GridLayout(1,6));
JButton btn_MC = new JButton("MC");
btn_MC.setForeground(Color.red);
JButton btn_7 = new JButton("7");
btn_7.setForeground(Color.BLUE);
btn_7.addActionListener(this);
JButton btn_8 = new JButton("8");
btn_8.setForeground(Color.BLUE);
btn_8.addActionListener(this);
JButton btn_9 = new JButton("9");
btn_9.setForeground(Color.BLUE);
btn_9.addActionListener(this);
JButton btn_wind= new JButton("/");
btn_wind.setForeground(Color.red);
JButton btn_sqrt = new JButton("sqrt");
btn_sqrt.setForeground(Color.BLUE);
p2_1.add(btn_MC); p2_1.add(btn_7);
p2_1.add(btn_8); p2_1.add(btn_9);
p2_1.add(btn_wind);p2_1.add(btn_sqrt);
JPanel p2_2 = new JPanel();
p2_2.setLayout(new GridLayout(1,6));
JButton btn_MR = new JButton("MR");
btn_MR.setForeground(Color.red);
JButton btn_4 = new JButton("4");
btn_4.setForeground(Color.BLUE);
btn_4.addActionListener(this);
JButton btn_5 = new JButton("5");
btn_5.setForeground(Color.BLUE);
btn_5.addActionListener(this);
JButton btn_6 = new JButton("6");
btn_6.setForeground(Color.BLUE);
btn_6.addActionListener(this);
JButton btn_star= new JButton("*");
btn_star.setForeground(Color.red);
JButton btn_mod = new JButton("%");
btn_mod.setForeground(Color.BLUE);
p2_2.add(btn_MR);
p2_2.add(btn_4); p2_2.add(btn_5);
p2_2.add(btn_6);
p2_2.add(btn_star);p2_2.add(btn_mod);
p2.add(p2_1);p2.add(p2_2); JPanel p3 = new JPanel();
p3.setLayout(new GridLayout(2,1));
JPanel p3_1 = new JPanel();
p3_1.setLayout(new GridLayout(1,6));
JButton btn_MS = new JButton("MS");
btn_MS.setForeground(Color.red);
JButton btn_1 = new JButton("1");
btn_1.setForeground(Color.BLUE);
btn_1.addActionListener(this);
JButton btn_2 = new JButton("2");
btn_2.setForeground(Color.BLUE);
btn_2.addActionListener(this);
JButton btn_3 = new JButton("3");
btn_3.setForeground(Color.BLUE);
btn_3.addActionListener(this);
JButton btn_sub= new JButton("-");
btn_sub.setForeground(Color.red);
JButton btn_reverse = new JButton("1/x");
btn_reverse.setForeground(Color.BLUE);
p3_1.add(btn_MS); p3_1.add(btn_1);
p3_1.add(btn_2); p3_1.add(btn_3);
p3_1.add(btn_sub);p3_1.add(btn_reverse);
JPanel p3_2 = new JPanel();
p3_2.setLayout(new GridLayout(1,6));
JButton btn_Madd = new JButton("M+");
btn_Madd.setForeground(Color.red);
JButton btn_0= new JButton("0");
btn_0.setForeground(Color.BLUE);
btn_0.addActionListener(this);
JButton btn_singal = new JButton("+/-");
btn_singal.setForeground(Color.BLUE);
btn_singal.addActionListener(this);
JButton btn_dot = new JButton(".");
btn_dot.addActionListener(this);
JButton btn_add= new JButton("+");
btn_add.setForeground(Color.red);
JButton btn_equal = new JButton("=");
btn_equal.setForeground(Color.red);
p3_2.add(btn_Madd);
p3_2.add(btn_0); p3_2.add(btn_singal);
p3_2.add(btn_dot);
p3_2.add(btn_add);p3_2.add(btn_equal);
p3.add(p3_1);p3.add(p3_2);
con.add(p1);con.add(p2);con.add(p3);
setVisible(true);
}
public void press_dot()
{
tag=false;
}

  运行结果
<ignore_js_op>

详细说明:http://java.662p.com/thread-2140-1-2.html

Windows计算机功能Java源码的更多相关文章

  1. 解密随机数生成器(二)——从java源码看线性同余算法

    Random Java中的Random类生成的是伪随机数,使用的是48-bit的种子,然后调用一个linear congruential formula线性同余方程(Donald Knuth的编程艺术 ...

  2. 基于JSP+Servlet开发在线租车系统 java 源码

    运行环境: 最好是java jdk 1.8,我们在这个平台上运行的.其他版本理论上也可以.IDE环境: Eclipse,Myeclipse,IDEA都可以tomcat环境: Tomcat 7.x,8. ...

  3. 如何阅读Java源码 阅读java的真实体会

    刚才在论坛不经意间,看到有关源码阅读的帖子.回想自己前几年,阅读源码那种兴奋和成就感(1),不禁又有一种激动. 源码阅读,我觉得最核心有三点:技术基础+强烈的求知欲+耐心.   说到技术基础,我打个比 ...

  4. 如何阅读Java源码

    刚才在论坛不经意间,看到有关源码阅读的帖子.回想自己前几年,阅读源码那种兴奋和成就感(1),不禁又有一种激动.源码阅读,我觉得最核心有三点:技术基础+强烈的求知欲+耐心. 说到技术基础,我打个比方吧, ...

  5. Java 源码学习线路————_先JDK工具包集合_再core包,也就是String、StringBuffer等_Java IO类库

    http://www.iteye.com/topic/1113732 原则网址 Java源码初接触 如果你进行过一年左右的开发,喜欢用eclipse的debug功能.好了,你现在就有阅读源码的技术基础 ...

  6. Java源码学习 -- java.lang.StringBuilder,java.lang.StringBuffer,java.lang.AbstractStringBuilder

    一直以来,都是看到网上说“ StringBuilder是线程不安全的,但运行效率高:StringBuffer 是线程安全的,但运行效率低”,然后默默记住:一个是线程安全.一个线程不安全,但对内在原因并 ...

  7. [收藏] Java源码阅读的真实体会

    收藏自http://www.iteye.com/topic/1113732 刚才在论坛不经意间,看到有关源码阅读的帖子.回想自己前几年,阅读源码那种兴奋和成就感(1),不禁又有一种激动. 源码阅读,我 ...

  8. 2018-09-15 Java源码英翻中库以及服务原型

    服务很简单, 只为演示这个库, 源码在: program-in-chinese/code_translator_service. 在Postman测试效果: 演示服务地址: 74.91.17.250: ...

  9. 如何阅读Java源码?

    阅读本文大概需要 3.6 分钟. 阅读Java源码的前提条件: 1.技术基础 在阅读源码之前,我们要有一定程度的技术基础的支持. 假如你从来都没有学过Java,也没有其它编程语言的基础,上来就啃< ...

随机推荐

  1. 帝国CMS商城功能高级使用

    一.常见问题1.为什么自定义模型加入购物车提示“非商城表的信息”?答:模型要使用商城的功能,要先到:后台>商城>商城参数设置:“指定使用商肠能的数据表”勾选你这个自定义模型表,才可以使用. ...

  2. 四步轻松实现用Visio画UML类图

    本节和大家一起学习一下用Visio画UML类图的方法,主要有四个步骤,这里和大家分享一下,相信通过本节的学习,你对Visio画UML类图的步骤一定会有所了解. 用Visio画UML类图 对于画类图的工 ...

  3. .Net调用非托管代码数据类型不一致的问题

    什么是Net互操作?.Net不能直接操作非托管代码,这时就需要互操作了.   c#中调用非托管c++函数,此函数又包含指向某个结构的指针,譬如指向c#中的byte数组.对于这样的参数,考虑到非托管变量 ...

  4. iOS推送通知的实现步骤

    一.关于推送通知 来源:http://blog.csdn.net/enuola/article/details/8627283 推送通知,也被叫做远程通知,是在iOS 3.0以后被引入的功能.是当程序 ...

  5. Good Sentences

    Wine in, truth out One is never too old to learn What is done can not be undone Time tries all thing ...

  6. Liferay 6开发学习(二十六):数据库连接相关问题

    Liferay中怎么更换数据库? 常碰到有人问Liferay怎么更换数据库,怎么修改数据库连接.在我们第一次启动Liferay的时候,会有一个配置向导,在此配置向导我们可以选择数据库,并配置数据库连接 ...

  7. .NET 添加/删除Cookie

    public class CookieHelper { /// <summary> /// 清除指定Cookie /// </summary> /// <param na ...

  8. java 、android 知识图谱

    java知识图谱: android知识图谱: 照此图练习,神功自成.....

  9. font awesome的图标在WP8浏览器下无法显示的问题解决

    font awesome无疑是bootstrap上面做的很赞第三方图标 笔者最近做的一个项目,图标在iphone和安卓上面的浏览器上显示都无问题,偏偏WP8上的浏览器显示有问题 通过chrome的开发 ...

  10. Rehat 5.8下oracle11g安装

    Oracle 11g Redhat 5安装  一.检查硬件是否满足要求 检查一内存 On Linux x86: At least 1 GB of RAM 内存至少1G To determine the ...