当前位置: 首页 > news >正文

jsp动态网站开发应用教程百度关键词排名推广工具

jsp动态网站开发应用教程,百度关键词排名推广工具,嘉定西安网站建设,用wordpress搭建网站实现控件的刷新 问题可以简化如下,点击上方按钮,使下方按钮移动,但要求在监听事件里新建按钮对象,而不是使用原来的按钮(原来的按钮被移除了)。 解决代码如下: public class TestUI {protecte…

实现控件的刷新

问题可以简化如下,点击上方按钮,使下方按钮移动,但要求在监听事件里新建按钮对象,而不是使用原来的按钮(原来的按钮被移除了)。

解决代码如下:

public class TestUI {protected Shell shell;Composite composite=null;	int i=0;public static void main(String[] args) {try {TestUI window = new TestUI();window.open();} catch (Exception e) {e.printStackTrace();}}public void open() {Display display = Display.getDefault();createContents();shell.open();shell.layout();while (!shell.isDisposed()) {if (!display.readAndDispatch()) {display.sleep();}}}protected void createContents() {shell = new Shell();shell.setMinimumSize(new Point(100, 20));shell.setMaximumSize(new Point(500, 400));shell.setSize(486,143);shell.setText("SWT Application");shell.setLayout(null);update();Button button = new Button(shell, SWT.NONE);button.addSelectionListener(new SelectionAdapter() {@Overridepublic void widgetSelected(SelectionEvent e) {update();i++;}});		button.setBounds(10, 10, 80, 27);button.setText("\u79FB\u52A8");}void update() {if(composite!=null)composite.dispose();composite = new Composite(shell, SWT.BORDER);composite.setBounds(10, 43, 450, 52);Button btnNewButton = new Button(composite, SWT.NONE);System.out.print(i);btnNewButton.setBounds(30*i, 10, 29, 27);}
}

扩展栏扩展项切换打开关闭

要实现打开一个扩展项时,关闭其他扩展项,需要给扩展栏添加扩展监听器。

关键代码如下:

expandBar.addExpandListener(new ExpandListener() {		@Overridepublic void itemExpanded(ExpandEvent arg0) {// TODO Auto-generated method stubSystem.out.println("expanded");for(ExpandItem item:expandBar.getItems()) {item.setExpanded(false);//这里循环设置其他扩展项关闭}}			@Overridepublic void itemCollapsed(ExpandEvent arg0) {// TODO Auto-generated method stub 这个不用管}});

日期时间设置

DateTime对象的getMonth()方法返回的月份从0(一月)到11(12月)。

设置日期时用setDate(int year,int month,int day)方法比较方便,合法的日期设置不会出现预料之外的结果,month的取值范围在0-11之间。

而如果年月日分别用setYear(),setMonth(),setDay()方法,年份无所谓,但月和日的结果可能受二者的先后次序影响。看如下示例:

DateTime dateTime1 = new DateTime(shell, SWT.BORDER); dateTime1.setBounds(359, 10, 101, 24);
System.out.println(dateTime1.getYear()+"-"+dateTime1.getMonth()+"-"+dateTime1.getDay());
//今天是2023-11-26,getMonth()获得的月份从0开始,上面输出2023-10-26,控件显示2020/11/26dateTime1.setYear(2022); dateTime1.setMonth(11); dateTime1.setDay(31);
System.out.println(dateTime1.getYear()+"-"+dateTime1.getMonth()+"-"+dateTime1.getDay());
//所以上面输出2022-11-31,控件显示2022/12/31dateTime1.setYear(2022); dateTime1.setMonth(10); dateTime1.setDay(30);
System.out.println(dateTime1.getYear()+"-"+dateTime1.getMonth()+"-"+dateTime1.getDay());
//先设置11月,上一次的31号保持不变。因为11月没有31号,所以月份设置失败,保持12月不变,再设置日期30号,12月有30号,上面输出2022-11-30,控件显示2020/12/30dateTime1.setYear(2021); dateTime1.setMonth(8); dateTime1.setDay(31);
System.out.println(dateTime1.getYear()+"-"+dateTime1.getMonth()+"-"+dateTime1.getDay());
//实际上设置9月31号,Day非法,不改变,只改变年和月.上行输出2021-8-30,控件显示2020/9/30dateTime1.setYear(2020); dateTime1.setMonth(1);	dateTime1.setDay(28);
System.out.println(dateTime1.getYear()+"-"+dateTime1.getMonth()+"-"+dateTime1.getDay());
//这里本想设置2月28号,先设置2月,但由于之前是30号,2月没有30号,所以month不变,day变,输出2020-8-28,控件显示2020/9/28
//但如果先设置Day为28号,再设置setMonth(1),则可以成功,下面输出2020-1-28,控件显示2020-2-28
//dateTime1.setYear(2020); dateTime1.setDay(28); dateTime1.setMonth(1);	
//System.out.println(dateTime1.getYear()+"-"+dateTime1.getMonth()+"-"+dateTime1.getDay());dateTime1.setYear(2019); dateTime1.setMonth(0); dateTime1.setDay(31);
System.out.println(dateTime1.getYear()+"-"+dateTime1.getMonth()+"-"+dateTime1.getDay());
//这里设置1月31号,输出2019-0-31,控件显示2019/1/31DateTime dateTime2 = new DateTime(shell, SWT.BORDER);
dateTime2.setBounds(359, 40, 98, 24);
dateTime2.setDate(2022, 11, 30);
System.out.println(dateTime2.getYear()+"-"+dateTime2.getMonth()+"-"+dateTime2.getDay());
//上面输出2022-11-30,控件显示2022/12/30dateTime2.setDate(2022, 1, 28);
System.out.println(dateTime2.getYear()+"-"+dateTime2.getMonth()+"-"+dateTime2.getDay());
//上面输出2022-1-28,控件显示2022/2/28,直接用setDate方法则无顺序之分

可以看出,当对月和日分别设置时,就像在拨动一个拨轮日历,同一时间只能调整月份或日期,且一个不能带动另一个。如果从12月31号调整到11月30号,如果先调整月份,日期保持31号,由于11月没有31号,则月份调整失败,保持12月不变,再将日期调整为30号,且月份不再调整。结果为12月30号而非11月30号。要想正确调整,需先将日期从31号调整为30号,再将月份从12月调整为11月。

而采用setDate()方法则一次性调整完成。

Composition类的扩展

Composition对象作为容器用于容纳其他控件,可以将其扩展以做一些初始化操作:

public class OperationComposite extends Composite {Statement statement;String userState;public OperationComposite(Composite parent, int style) {super(parent, style);	}public OperationComposite(Shell shell, Composite parent, int style,String newAccount,String newRole,String tableName,String[] btnStrArray,String[] tableHeadersStrArray,ResultSet resultSet,Statement newStatement) {super(parent, style);statement=newStatement;Composite menuComposite=new Composite(parent, SWT.None);		menuComposite.setBounds(10, 10, 722, 35);Group group=new Group(parent, SWT.CENTER);//group.setText(tableName);group.setBounds(10, 51, 722, 243);}@Overrideprotected void checkSubclass() {// Disable the check that prevents subclassing of SWT components}
}

Table类的扩展

Table对象用于将数据以表格形式展示,可以将其扩展以完成一些初始化操作:

public class ExtendedTable extends Table{String[] headerStrArray;String[] contextStrArray= {};String contextStr;static Shell shell;protected void checkSubclass() {        // TODO Auto-generated method stub        }public ExtendedTable(Composite composite,int i) {super(composite, i);// TODO Auto-generated constructor stub}public ExtendedTable(Shell shell,Group group, int style,String newAccount,String newRole,String tableName,String[] headerStrArray,Statement statement,ResultSet resultSet) {// TODO Auto-generated constructor stubsuper(group, style);//super(shell, style);		//Table table=new Table(group, 0);setHeaderVisible(true); setLinesVisible(true);}
}

http://www.hkea.cn/news/115997/

相关文章:

  • wordpress居中样式宁波seo网络推广外包报价
  • java做网站用到哪些技术网络营销的重要性与意义
  • 网络营销推广的作用谷歌seo什么意思
  • 免费网站建设解决方案郑州网络营销公司哪个好
  • 转转怎么做钓鱼网站税收大数据
  • 株洲专业网站排名优化深圳产品网络推广
  • 深圳美食教学网站制作如何免费搭建自己的网站
  • 兰州移动端网站建设广东整治互联网霸王条款
  • 彩票网站该怎么建设天津seo实战培训
  • 原平的旅游网站怎么做的新冠疫情最新情况最新消息
  • 网站开发软件著作权归谁seo外包
  • 小说网站的网编具体做哪些工作南宁网站快速排名提升
  • 承德网站设计seo互联网营销培训
  • 工信部网站备案查询 手机seo专员的工作内容
  • 淘宝活动策划网站视频营销成功的案例
  • 精准营销数据杭州排名优化软件
  • 中卫网站建站设计seo学习论坛
  • wordpress初始登录seo排名赚app靠谱吗
  • 软件外包保密协议seo相关岗位
  • 后台网站开发文档下载班级优化大师app
  • 辛集城乡建设管理局网站网络营销网络推广
  • 阿里云部署一个自己做的网站吗电商网站搭建
  • 免费汽车租赁网站模板网站域名解析ip查询
  • 企业解决方案官网国内seo排名分析主要针对百度
  • 变态版手游石景山区百科seo
  • 阿里云控制台登录入口seo矩阵培训
  • wordpress苗木模板网站搜索排优化怎么做
  • 网站图片引导页怎么做重庆seo招聘
  • 如何做属于自己的领券网站郑州百度网站优化排名
  • 建设银行益阳市分行桃江支行网站公司页面设计