演示代码如下:
package swt_jface.demo9; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Sash; import org.eclipse.swt.widgets.Shell; public class SashExample {public static void main(String[] args) {Display display = new Display();Shell shell = new Shell(display);final Sash sash = new Sash(shell, SWT.BORDER | SWT.VERTICAL);sash.setBounds(10, 10, 15, 60);sash.addListener(SWT.Selection, new Listener() {public void handleEvent(Event e) {System.out.println("Selected. ");sash.setBounds(e.x, e.y, e.width, e.height);}});shell.open();sash.setFocus();while (!shell.isDisposed()) {if (!display.readAndDispatch())display.sleep();}display.dispose();} }
再来一个例子:
package swt_jface.demo9; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; public class SashFormExample {Display display = new Display();Shell shell = new Shell(display);SashForm sashForm;SashForm sashForm2;public SashFormExample() {shell.setLayout(new FillLayout());sashForm = new SashForm(shell, SWT.HORIZONTAL);Text text1 = new Text(sashForm, SWT.CENTER);text1.setText("Text in pane #1");Text text2 = new Text(sashForm, SWT.CENTER);text2.setText("Text in pane #2");sashForm2 = new SashForm(sashForm, SWT.VERTICAL);final Label labelA = new Label(sashForm2, SWT.BORDER | SWT.CENTER);labelA.setText("Label in pane A");final Label labelB = new Label(sashForm2, SWT.BORDER |SWT.CENTER);labelB.setText("Label in pane B");text1.addControlListener(new ControlListener() {public void controlMoved(ControlEvent e) {}public void controlResized(ControlEvent e) {System.out.println("Resized");//ArrayUtil.printArray(sashForm.getWeights(), System.out);}});sashForm.setWeights(new int[]{1, 2, 3});labelA.addMouseListener(new MouseListener() {public void mouseDoubleClick(MouseEvent e) {if(sashForm2.getMaximizedControl() == labelA)sashForm2.setMaximizedControl(null);elsesashForm2.setMaximizedControl(labelA);}public void mouseDown(MouseEvent e) {}public void mouseUp(MouseEvent e) {}});shell.setSize(450, 200);shell.open();while (!shell.isDisposed()) {if (!display.readAndDispatch()) {display.sleep();}}display.dispose();}public static void main(String[] args) {new SashFormExample();} }
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
Duilib中list控件支持ctrl和shif多行选中的实现
[ICML2015]Batch Normalization:Accelerating Deep Network Training by Reducing Internal Covariate Shif
win10系统 微软输入法 于eclipse ctrl+shif+f冲突间接处理办法
Codeforces Round #259 (Div. 2) B. Little Pony and Sort by Shif
读LDD3,内存映射与DMA--PAGE_SHIF…
VMware虚拟机安装XP【要先分区,再设置BOOT 启动CD,shif+上移】
更换iBus五笔的左与右Shif
sublime ctrl+shif+f 没用解决办法
idea 对 ctrl + z 的撤销 是 ctrl + shif + z
计算机最早的设计师应用于,计算机应用基础选择题doc.doc
win10自带截图神器:Win+Shift+S
Python基础之文件目录操作
python简述目录_Python基础之文件目录操作(示例代码)
tp5 如何做数据采集
任务2-7(服务器字体+阿里巴巴矢量库)
html标签(1):h1~h6,p,br,pre,hr
TI 电量计介绍与芯片选型指南
几款TI电源芯片简介
TI DSP芯片C2000系列读取FLASH数据
德州仪器(Ti)平台嵌入式开发基础
TI三相电机智能栅极驱动芯片特点分类
省选模拟(12.08) T3 圈圈圈圈圈圈圈圈
Hadoop生态圈技术栈(上)
大数据开发基础入门与项目实战(三)Hadoop核心及生态圈技术栈之6.Impala交互式查询
小猿圈之Linux下Mysql 操作命令
大数据Hadoop生态圈常用面试题
大数据开发基础入门与项目实战(三)Hadoop核心及生态圈技术栈之4.Hive DDL、DQL和数据操作
备战Noip2018模拟赛11(B组)T3 Monogatari 物语
【智能优化算法-圆圈搜索算法】基于圆圈搜索算法Circle Search Algorithm求解单目标优化问题附matlab代码
NYOJ 78 圈水池
递归问题 跑道 汽车 绕圈问题 Python实现
Hadoop生态圈(三):MapReduce
微信公众账号
微信扫一扫加关注