java---计算器图形界面(无功能)
【摘要】 package cn.hncu.chx1;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GridLayout;
import ...
package cn.hncu.chx1;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextArea;
import java.awt.TextField;
public class jisuanqi extends Frame{ public jisuanqi(){ super("计算器"); String aa[]={"MC","MR","MS","M+","M-","←","CE","C","±","√","7","8","9","/","%","4","5","6","*","1/x","1","2","3","-","=","0",".","+"}; this.setLocation(400, 300); //显示位置 this.setSize(250, 320); //组件宽和高 this.setBackground(new Color(224,238,238)); //this.setLayout(new FlowLayout(0));流布局 Panel p = new Panel(); //new 一个面板 p.setSize(230, 30); p.setBackground(new Color(230,230,250)); this.add(p,BorderLayout.NORTH); p.add(new Label("查看(V)")); p.add(new Label("编辑(E)")); p.add(new Label("帮助(H)")); this.add(new TextArea(28,10)); Panel p1 = new Panel(); p1.setSize(250, 100); p1.setBackground(new Color(224,238,238)); this.add(p1,BorderLayout.SOUTH); p1.setLayout(new GridLayout(6, 5,8,8)); Button btns[]; btns = new Button[35]; for(int i=0;i<aa.length;i++){ btns[i] = new Button(aa[i]); p1.add(btns[i]); } p1.add(new Label(""),26); p1.add(new Label(""),28); this.setResizable(false); //不可以调大小 setVisible(true); //显示组件可见 } public static void main(String[] args) { new jisuanqi(); }
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
文章来源: chenhx.blog.csdn.net,作者:谙忆,版权归原作者所有,如需转载,请联系作者。
原文链接:chenhx.blog.csdn.net/article/details/49799603
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)