用户图形界面的实现
来源:互联网 发布:天津网络报警平台 编辑:程序博客网 时间:2024/05/18 03:33
package work_15;import java.awt.Button;import java.awt.Color;import java.awt.Component;import java.awt.Font;import java.awt.Frame;import java.awt.GridLayout;import java.awt.Label;import java.awt.TextField;import java.awt.Window;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowEvent;import java.awt.event.WindowListener;public class lalala extends Frame implements WindowListener, ActionListener {private Button b1,b2,b3,b4,b5;private Label L1,L2,L3,L4,L5;private TextField t1,t2,t3;public void actionPerformed(ActionEvent xpp) {String n;n=xpp.getActionCommand();if(n.equals("连接")){String m=t1.getText().concat(t2.getText());t3.setText(m);}if(n.equals("加")){String a=t1.getText();String b=t2.getText();double c=Double.parseDouble(a)+Double.parseDouble(b);t3.setText(c+"");}if(n.equals("乘")){String a=t1.getText();String b=t2.getText();double c=Double.parseDouble(a)*Double.parseDouble(b);t3.setText(c+"");}if(n.equals("减")){String a=t1.getText();String b=t2.getText();double c=Double.parseDouble(a)-Double.parseDouble(b);t3.setText(c+"");}if(n.equals("除")){String a=t1.getText();String b=t2.getText();double c=Double.parseDouble(a)+Double.parseDouble(b);t3.setText(c+"");}else if(n.equals("清除")){t1.setText("");t2.setText("");t3.setText("");}}public void windowActivated(WindowEvent e) {}public void windowClosed(WindowEvent xpp) {}public void windowClosing(WindowEvent xpp) {Window f=(Window)xpp.getSource();f.setVisible(false);f.dispose();}public void windowDeactivated(WindowEvent e) {}public void windowDeiconified(WindowEvent e) {}public void windowIconified(WindowEvent e) {}public void windowOpened(WindowEvent e) {}public lalala(){super("基本运算");setLocation(300,500);setSize(600,200);setLayout(new GridLayout(3,5,5,5));//行列水平竖直间距Font f=new Font("宋体",Font.ITALIC,25);//字体型号setFont(f);setForeground(Color.yellow);setBackground(Color.darkGray);b1=new Button("连接");b2=new Button("清除");b3=new Button("加");b4=new Button("乘");b5=new Button("减");L1=new Label("+");L2=new Label("=");L3=new Label("第一个数");L4=new Label("第二个数");L5=new Label("结果");t1=new TextField();t2=new TextField();t3=new TextField();add(L3);add(new Label());add(L4);add(new Label());add(L5);add(t1);add(L1);add(t2);add(L2);add(t3);add(b1);add(b4);add(b3);add(b5);add(b2);b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);b4.addActionListener(this);b5.addActionListener(this);addWindowListener(this);//关闭窗口}public static void main(String[] args) {lalala w=new lalala();w.setVisible(true);}}
阅读全文
0 0
- 用户图形界面的实现
- 用户图形界面滚动条的实现
- 用户图形界面的创建
- 嵌入式系统中数字示波器用户图形界面的实现
- 一些有趣的用户图形界面(do--while实现)
- 用户图形界面的概念(读书笔记)
- useradd 用户不能登录图形界面的问题
- JAVA__大作业_4_3X题目用户图形界面实现
- GUI/用户图形界面
- java用户图形界面
- 图形界面模拟一个顺序栈的实现
- 动态更新图形界面的实现一例
- Java 实现图形界面的邮件轰炸机
- ubuntu12.04中root用户的启用和图形界面
- linux不允许root用户登录图形界面的解决办法
- 黑马程序员--GUI(用户图形界面)
- 基于JS的WEB会议室预订拖拽式图形界面的实现
- 基于JS的WEB会议室预订拖拽式图形界面的实现
- 程序员面试宝典随笔记(一)---线程和进程1,-基础信息
- latex常用的基本操作
- git教程
- 看家本领之一:软件测试的系统性思维
- Python文本处理笔记(readlines去掉回车+string list to int list)
- 用户图形界面的实现
- EnhanceNet的简要笔记
- 如何让UDP也可靠
- 杭电acm P2021 发工资咯
- Harbor -- 搭建Docker私有仓库
- 数据库操作类采用PDO形式完成基本增删改查
- selenium+python自动化测试(3)
- [LeetCode] 83. Remove Duplicates from Sorted List ❤
- 关于stdlib头文件