已阅读5页,还剩14页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
(1)package ch2;import org.eclipse.swt.layout.GridLayout;import org.eclipse.swt.graphics.Point;import org.eclipse.swt.widgets.MessageBox;import org.eclipse.swt.widgets.Shell;import org.eclipse.swt.widgets.Display;import org.eclipse.swt.widgets.Label;import org.eclipse.swt.SWT;import org.eclipse.swt.graphics.Rectangle;import org.eclipse.swt.graphics.Font;import org.eclipse.swt.widgets.Text;import org.eclipse.swt.widgets.Button;public class P32 private Shell sShell = null; / jve:decl-index=0:visual-constraint=20,9private Label label = null;private Text text = null;private Button button = null;/* * param args */public static void main(String args) / TODO 自动生成方法存根/* Before this is run, be sure to set up the launch configuration (Arguments-VM Arguments) * for the correct SWT library path in order to run with the SWT dlls. * The dlls are located in the SWT plugin jar. * For example, on Windows the Eclipse SWT 3.1 plugin jar is: * installation_directorypluginsorg.eclipse.swt.win32_3.1.0.jar */Display display = Display.getDefault();P32 thisClass = new P32();thisClass.createSShell();thisClass.sShell.open();while (!thisClass.sShell.isDisposed() if (!display.readAndDispatch()display.sleep();display.dispose();/* * This method initializes sShell */private void createSShell() sShell = new Shell();sShell.setText(Shell);sShell.setSize(new Point(300, 200);sShell.setLayout(null);label = new Label(sShell, SWT.NONE);label.setBounds(new Rectangle(2, 21, 134, 38);label.setFont(new Font(Display.getDefault(), u6977u4f53_GB2312, 12, SWT.NORMAL);label.setText(请输入一个年份数);text = new Text(sShell, SWT.BORDER);text.setBounds(new Rectangle(153, 23, 130, 39);button = new Button(sShell, SWT.NONE);button.setBounds(new Rectangle(99, 88, 66, 40);button.setText(确定);button.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) MessageBox box=new MessageBox(sShell,SWT.ICON_WARNING|SWT.OK);box.setText(java 课堂);String s=text.getText();int y=Integer.parseInt(s);Boolean b1=(y%4=0)&(y%100!=0),b2=(y%400=0);String str=(b1|b2)?是:不是;box.setMessage(s+年+str+闰年);box.open(););(2)package ch2;public class P34 extends P32 /* * param args */public static void main(String args) / TODO 自动生成方法存根char a1=十,a2=点,a3=进,a4=攻;char secret=8;a1=(char)(a1secret);a2=(char)(a2secret);a3=(char)(a3secret);a4=(char)(a4secret);System.out.println(密文:+a1+a2+a3+a4);a1=(char)(a1secret);a2=(char)(a2secret);a3=(char)(a3secret);a4=(char)(a4secret); System.out.println(原文:+a1+a2+a3+a4);(3)package ch2;import org.eclipse.swt.layout.GridLayout;import org.eclipse.swt.graphics.Point;import org.eclipse.swt.widgets.Shell;import org.eclipse.swt.widgets.Display;import org.eclipse.swt.widgets.Button;import org.eclipse.swt.SWT;import org.eclipse.swt.graphics.Rectangle;import org.eclipse.swt.widgets.MessageBox;public class P36 private Shell sShell = null;private Button button = null;private Button button1 = null;byte b=0x7f; short s=0x7fff; int i=0x7fffffff; long l=0x7fffffffffffffffL; char c=字; float f=3.4E38F; double d=1.797631E308; boolean B=true; String S=北京欢迎你;/* * param args */public static void main(String args) / TODO 自动生成方法存根/* Before this is run, be sure to set up the launch configuration (Arguments-VM Arguments) * for the correct SWT library path in order to run with the SWT dlls. * The dlls are located in the SWT plugin jar. * For example, on Windows the Eclipse SWT 3.1 plugin jar is: * installation_directorypluginsorg.eclipse.swt.win32_3.1.0.jar */Display display = Display.getDefault();P36 thisClass = new P36();thisClass.createSShell();thisClass.sShell.open();while (!thisClass.sShell.isDisposed() if (!display.readAndDispatch()display.sleep();display.dispose();/* * This method initializes sShell */private void createSShell() sShell = new Shell();sShell.setText(Shell);sShell.setSize(new Point(300, 200);sShell.setLayout(null);button = new Button(sShell, SWT.NONE);button.setText(变量);button.setSize(new Point(75, 25);button.setLocation(new Point(53, 99);button.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) MessageBox box=new MessageBox(sShell,SWT.ICON_WARNING|SWT.OK); box.setText(各种类型数据); String str=字符型变量 c=+c+n; str=str+布尔型变量 b=+b+n; str=str+字符串类对象 S=+S+nn; str=str+数值型数据的最大值 : n; str=str+字节型变量 b=+b+n; str=str+短整型变量 s=+s+n; str=str+整型变量 i=+i+n; str=str+长整型变量 l=+l+n; str=str+浮点型变量 f=+f+n; str=str+双精度变量 d=+d+n; box.setMessage(str); box.open(););button.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) );button1 = new Button(sShell, SWT.NONE);button1.setText(转换);button1.setSize(new Point(73, 28);button1.setLocation(new Point(154, 96);button1.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) MessageBox box=new MessageBox(sShell,SWT.ICON_WARNING|SWT.OK); String str=; str=str+双精度变量 d=+d+n; str=str+转换为浮点型 :+(float)d+n; str=str+转换为长整型 :+(long)d+n; str=str+转换为整型 :+(int)d+n; str=str+转换为短整型 :+(short)d+n; str=str+转换为字节型 :+(byte)d+n; box.setText(强制类型转换); box.setMessage(str); box.open(););(4)package ch2;import org.eclipse.swt.layout.GridLayout;import org.eclipse.swt.graphics.Point;import org.eclipse.swt.widgets.Shell;import org.eclipse.swt.widgets.Display;import org.eclipse.swt.widgets.Label;import org.eclipse.swt.SWT;import org.eclipse.swt.graphics.Rectangle;import org.eclipse.swt.widgets.Text;import org.eclipse.swt.widgets.Button;import org.eclipse.swt.widgets.MessageBox;public class P38 private Shell sShell = null;private Label label = null;private Text text = null;private Button button = null;private Button button1 = null; int a,b,c;/* * param args */public static void main(String args) / TODO 自动生成方法存根/* Before this is run, be sure to set up the launch configuration (Arguments-VM Arguments) * for the correct SWT library path in order to run with the SWT dlls. * The dlls are located in the SWT plugin jar. * For example, on Windows the Eclipse SWT 3.1 plugin jar is: * installation_directorypluginsorg.eclipse.swt.win32_3.1.0.jar */Display display = Display.getDefault();P38 thisClass = new P38();thisClass.createSShell();thisClass.sShell.open();while (!thisClass.sShell.isDisposed() if (!display.readAndDispatch()display.sleep();display.dispose();/* * This method initializes sShell */private void createSShell() sShell = new Shell();sShell.setText(Shell);sShell.setSize(new Point(300, 200);sShell.setLayout(null);label = new Label(sShell, SWT.NONE);label.setBounds(new Rectangle(35, 29, 67, 37);label.setText(准备答题);text = new Text(sShell, SWT.BORDER);text.setBounds(new Rectangle(136, 29, 126, 45);button = new Button(sShell, SWT.NONE);button.setBounds(new Rectangle(43, 106, 91, 44);button.setText(出题);button.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) String str=; a=(int)(Math.random()*90)+10; b=(int)(Math.random()*90)+10; str=Integer.toString(a)+Integer.toString(b)+=; label.setText(str); text.setText(); text.setFocus(););button1 = new Button(sShell, SWT.NONE);button1.setBounds(new Rectangle(146, 108, 96, 42);button1.setText(提交);button1.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) MessageBox box=new MessageBox(sShell,SWT.ICON_WARNING|SWT.OK);c=Integer.parseInt(text.getText();box.setText(加法练习);box.setMessage(c=a+b?恭喜你,答对了!:再想一想);box.open(););(5)package ch2;import org.eclipse.swt.layout.GridLayout;import org.eclipse.swt.graphics.Point;import org.eclipse.swt.widgets.MessageBox;import org.eclipse.swt.widgets.Shell;import org.eclipse.swt.widgets.Display;import org.eclipse.swt.widgets.Label;import org.eclipse.swt.SWT;import org.eclipse.swt.graphics.Rectangle;import org.eclipse.swt.widgets.Text;import org.eclipse.swt.widgets.Button;import org.eclipse.swt.widgets.MessageBox;public class P39 private Shell sShell = null;private Label label = null;private Text text = null;private Button button = null;/* * param args */public static void main(String args) / TODO 自动生成方法存根/* Before this is run, be sure to set up the launch configuration (Arguments-VM Arguments) * for the correct SWT library path in order to run with the SWT dlls. * The dlls are located in the SWT plugin jar. * For example, on Windows the Eclipse SWT 3.1 plugin jar is: * installation_directorypluginsorg.eclipse.swt.win32_3.1.0.jar */Display display = Display.getDefault();P39 thisClass = new P39();thisClass.createSShell();thisClass.sShell.open();while (!thisClass.sShell.isDisposed() if (!display.readAndDispatch()display.sleep();dis
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026事业单位工勤技能-天津-天津护理员一级(高级技师)历年参考题库含答案详解
- 2026事业单位工勤技能-吉林-吉林水工闸门运行工三级(高级工)历年参考题库含答案详解
- 2026事业单位工勤技能-内蒙古-内蒙古堤灌维护工五级(初级工)历年参考题库含答案详解
- 2026事业单位工勤技能-云南-云南城管监察员四级(中级工)历年参考题库含答案详解
- 2026事业单位工勤技能-上海-上海家禽饲养员四级(中级工)历年参考题库含答案详解
- 2026G锅炉特种作业-锅炉水处理(官方)-法规标准知识参考试题库历年考点答案详解
- 2026年7月轻型商用车市场预测研究报告
- -七年级上学期第1次周练英语试题B
- 2026年顺昌县网格员招聘考试参考题库及答案解析
- 2026年武宣县中小学幼儿园教师招聘考试模拟试题及答案解析
- 2026年秋季开学幼儿园秋季传染病防控课件
- 北京市房山区卫生健康委员会所属事业单位招聘笔试真题2025
- 2026年部编版新教材道德与法治四年级上册全册教案设计(共4个单元含教学计划)
- 重卡超级充电站场站布局设计
- 国家能源集团《火力发电工程建设安全标准化图册》
- 2026年北京市高考英语试卷(含答案及解析)
- 吉利汽车GEELY+品牌VI手册 Geely Auto Communication Guidelines (New Energy 2025)
- 江苏省徐州市区2025-2026学年五年级下学期数学期末试题一(试卷+答案)
- 膝关节韧带损伤护理指南
- 《思想政治教育学原理》教学课件
- 高考英语复习读后续写练习 善举篇 改变家乡为无法使用操场的孩子们带来福音 课件
评论
0/150
提交评论