package Calculator;
import java.text.DecimalFormat;
/*
本作品由西南大学荣昌校区09计科2班 杨晓骏 制作
*/
public class Calculator extends SelectionAdapter implements VerifyListener{
protected Shell shell;
private Text text;
private final FormToolkit formToolkit = new FormToolkit(
Display.getDefault());
private Composite composite;
private Composite composite_1;
private Button btnNewButton;
private Button btnNewButton_1;
private Button btnNewButton_2;
private Button btnNewButton_3;
private Button Number_1;
private Button Number_2;
private Button Number_3;
private Button btnNewButton_7;
private Button Number_4;
private Button Number_5;
private Button Number_6;
private Button btnNewButton_11;
private Button Number_7;
private Button Number_8;
private Button Number_9;
private Button btnNewButton_15;
private Button Number_0;
private Button btnNewButton_17;
private Button btnNewButton_18;
private Button btnNewButton_19;
private Button btnNewButton_20;
private Button btnNewButton_21;
private Button btnNewButton_22;
private Button btnNewButton_23;
private Button btnNewButton_24;
private Button btnNewButton_25;
private Button btnNewButton_26;
private DecimalFormat df;
private boolean click_Flag = true;
boolean isContinue = false;
private double memory_Data;
private double middle, result;
private short key = -1, prekey = -1;
private boolean isInclude, isInputNumber = false;
private Text text_1;
private Text text_2;
private Menu menu;
private MenuItem mntmNewSubmenu;
private Menu menu_1;
private MenuItem mntmNewItem;
private String s;
/**
* Launch the application.
*
* @param args
*/
public static void main(String[] args) {
try {
new Calculator();
} catch (Exception e) {
e.printStackTrace();
}
}
public Calculator() {
Display display = Display.getDefault(); // 构造界面
shell = new Shell(SWT.CLOSE | SWT.MIN);
shell.setImage(SWTResourceManager.getImage(Calculator.class,
"/org/eclipse/jface/dialogs/images/help.gif"));
shell.setAlpha(255);
shell.setSize(396, 755);
shell.setText("\u5C0F\u7070\u72FC\u8BA1\u7B97\u5668");
shell.setLayout(new FormLayout());
composite = new Composite(shell, SWT.NONE);
composite.setLayout(new FormLayout());
FormData fd_composite = new FormData();
fd_composite.top = new FormAttachment(0);
fd_composite.left = new FormAttachment(0);
fd_composite.right = new FormAttachment(100);
composite.setLayoutData(fd_composite);
composite_1 = new Composite(shell, SWT.NONE);
fd_composite.bottom = new FormAttachment(100, -469);
FormData fd_composite_1 = new FormData();
fd_composite_1.top = new FormAttachment(composite, 6);
fd_composite_1.bottom = new FormAttachment(100, -10);
fd_composite_1.left = new FormAttachment(0);
fd_composite_1.right = new FormAttachment(100);
text = new Text(composite, SWT.BORDER | SWT.RIGHT);
text.setText("0");
text.setEditable(false);
text.addVerifyListener(this);
text.setFont(SWTResourceManager.getFont("微软雅黑", 48, SWT.BOLD));
text.setTextLimit(15);
text.setBackground(SWTResourceManager.getColor(255, 255, 204));
FormData fd_text = new FormData();
fd_text.bottom = new FormAttachment(0, 86);
fd_text.top = new FormAttachment(0);
fd_text.left = new FormAttachment(0);
fd_text.right = new FormAttachment(100);
text.setLayoutData(fd_text);
btnNewButton = new Button(composite, SWT.NONE);
btnNewButton.addSelectionListener(this);
btnNewButton.setFont(SWTResourceManager.getFont("微软雅黑", 48, SWT.BOLD));
btnNewButton.setText("\u2192");
FormData fd_btnNewButton = new FormData();
btnNewButton.setLayoutData(fd_btnNewButton);
formToolkit.adapt(btnNewButton, true, true);
btnNewButton_1 = new Button(composite, SWT.NONE);
fd_btnNewButton.right = new FormAttachment(btnNewButton_1, -6);
btnNewButton_1.addSelectionListener(this);
btnNewButton_1
.setFont(SWTResourceManager.getFont("微软雅黑", 28, SWT.BOLD));
FormData fd_btnNewButton_1 = new FormData();
fd_btnNewButton_1.left = new FormAttachment(0, 232);
btnNewButton_1.setLayoutData(fd_btnNewButton_1);
formToolkit.adapt(btnNewButton_1, true, true);
btnNewButton_1.setText("CE");
btnNewButton_2 = new Button(composite, SWT.NONE);
fd_btnNewButton_1.right = new FormAttachment(100, -85);
btnNewButton_2.addSelectionListener(this);
btnNewButton_2
.setFont(SWTResourceManager.getFont("微软雅黑", 28, SWT.BOLD));
FormData fd_btnNewButton_2 = new FormData();
fd_btnNewButton_2.left = new FormAttachment(btnNewButton_1, 6);
fd_btnNewButton_2.right = new FormAttachment(100, -6);
btnNewButton_2.setLayoutData(fd_btnNewButton_2);
formToolkit.adapt(btnNewButton_2, true, true);
btnNewButton_2.setText("C");
text_1 = new Text(composite, SWT.BORDER | SWT.CENTER);
fd_btnNewButton_2.bottom = new FormAttachment(text_1, 70, SWT.BOTTOM);
fd_btnNewButton_1.bottom = new FormAttachment(text_1, 70, SWT.BOTTOM);
fd_btnNewButton_2.top = new FormAttachment(text_1, 6);
fd_btnNewButton_1.top = new FormAttachment(text_1, 6);
fd_btnNewButton.bottom = new FormAttachment(text_1, 70, SWT.BOTTOM);
fd_btnNewButton.top = new FormAttachment(text_1, 6);
text.setTextLimit(15);
text_1.setFont(SWTResourceManager.getFont("微软雅黑", 30, SWT.NORMAL));
text_1.setEditable(false);
text_1.setText("0");
text_1.setBackground(SWTResourceManager.getColor(255, 255, 102));
FormData fd_text_1 = new FormData();
fd_text_1.bottom = new FormAttachment(text, 70, SWT.BOTTOM);
fd_text_1.top = new FormAttachment(text, 6);
fd_text_1.left = new FormAttachment(0);
fd_text_1.right = new FormAttachment(100);
text_1.setLayoutData(fd_text_1);
formToolkit.adapt(text_1, true, true);
text_2 = new Text(composite, SWT.BORDER | SWT.CENTER);
fd_btnNewButton.left = new FormAttachment(text_2, 6);
text_2.setEditable(false);
text_2.setFont(SWTResourceManager.getFont("微软雅黑", 35, SWT.NORMAL));
FormData fd_text_2 = new FormData();
fd_text_2.bottom = new FormAttachment(text_1, 70, SWT.BOTTOM);
fd_text
相关推荐
javaSWT简易计算器
java用SWT制作界面的简易计算器,可实现加减乘除和小数的运算
用SWT做的WIndows自带的计算器
主要用SWT编写,完成了系统自带的计算器的所有功能,包括加,减,乘,除,以及求摸,包括科学型,标准型,数字型三个界面的设计。
DEAP数据集实战:用PyTorch搭建DNN/CNN脑电情绪识别模型(附完整代码)
本文详细介绍了如何使用PyTorch搭建DNN和CNN模型对DEAP数据集进行脑电情绪识别。从数据预处理到模型架构设计,再到训练优化和部署,提供了完整的实战指南和代码示例,帮助研究者快速掌握脑电信号识别技术。
从0死磕全栈之使用 VS Code 调试 Next.js 应用完整指南
调试目标推荐方式客户端组件VS Code + Chrome 调试器(pwa-chrome中间件(Middleware)同服务端方式静态生成(SSG)逻辑需在next build时调试,建议改用dynamic路由临时测试通过合理配置 VS Code 调试器,你可以像调试普通 Node.js 或前端项目一样,高效排查 Next.js 应用中的各类问题。🐞。
Win7/Win10双系统兼容指南:Arduino IDE 1.8.19与2.3.2的安装避坑全攻略
本文详细解析了在Win7/Win10双系统环境下安装和配置Arduino IDE 1.8.19与2.3.2版本的完整指南,特别针对ESP32开发环境的深度配置和COM端口常见问题提供了实用解决方案。通过版本对比、安装优化和性能调优,帮助开发者高效搭建稳定的物联网开发环境。
QGIS插件实战:用百度地图AOI数据做个城市公园分析,从下载到出图全记录
本文详细介绍了如何利用QGIS的百度地图AOI插件进行城市公园分析,从插件安装、数据获取到空间分析与可视化全流程。通过实战案例演示了公园面积统计、服务范围缓冲区分析及专题地图制作,帮助用户高效完成城市绿地评估工作。
【AirSim+PX4】WSL2上运行PX4连接Airsim步骤
在 Linux 命令行中输入以下命令以添加(或改变)环境变量。注意,此处的 IP 地址应为。4.启动 sln 文件的调试以进入 UE4 编辑器,并在 Linux 中启动 PX4。
智能办公助手——OpenClaw办公自动化集成(2026办公版)
OpenClaw智能办公助手是一款集成任务管理、文档处理等功能的办公自动化系统。该系统采用Python实现,核心功能包括:1)任务管理系统,支持任务增删改查、状态跟踪和统计报表生成;2)文档智能助手,提供文档处理能力。任务管理模块具备优先级设置、状态变更、时间记录等功能,并能生成包含完成率等指标的任务报告。该系统旨在通过自动化办公流程提升工作效率,减少重复性工作。开发者可利用这些模块构建完整的智能办公解决方案。
西门子S7-1200PLC控制步进电机的组态编程和具体步骤
西门子S7-1200PLC控制步进电机的组态编程和具体步骤 硬件准备: 1) 一个S7-1214C DC/DC/DC,订货号:6ES7 214-1AG40-0XB0 2) 一个86系的步进电机+相应的驱动器 3) 一个20A的西门子24V电源(步进驱动器及plc电源) 4) Portal V15版本 组态及编程: 1) 创建一个验证项目,添加cpu( S7-1214C),双击“工艺对象”,选择“运动控制”的TO_PositioningAxis V6.0版本,如下图所示: 2) “确定”后,系统自动生成名
S/4HANA 迁移前的必修课:用 SCMON 找出沉睡的自定义代码
SAP S/4HANA迁移项目中,SCMON工具能有效解决历史代码评估难题。通过监控ABAP对象调用情况,SCMON可识别40-60%处于"沉睡"状态的自定义代码。配置时需注意监控周期(建议3-6个月)和数据保留期(建议1年),并配合Time Slices功能进行时段分析。工具导出的调用数据可与测试覆盖率对比,帮助决策代码迁移优先级。实际应用中需结合业务场景,建议与SUSG工具配合使用,并保持持续监控。SCMON虽不能完全替代人工判断,但其提供的客观数据能显著提升迁移决策的科学性,建议在
温度PID控制PLC程序
温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值
OV9734 DATASHEET,完整规格书
OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
NTscan扫描工具
ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。
392



被折叠的 条评论
为什么被折叠?



