时间:2021-05-20
演示代码如下:
复制代码 代码如下:
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.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);
else
sashForm2.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();
}
}
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
演示代码:复制代码代码如下:packageswt_jface.demo9;importorg.eclipse.swt.SWT;importorg.eclipse
测试代码如下:复制代码代码如下:packageswt_jface.demo2;importorg.eclipse.swt.SWT;importorg.eclip
Slider:复制代码代码如下:packageswt_jface.demo8;importorg.eclipse.swt.SWT;importorg.eclip
代码如下复制代码代码如下:packageswt_jface.demo;importorg.eclipse.swt.SWT;importorg.eclipse.s
演示代码如下:复制代码代码如下:packageswt_jface.demo11;importorg.eclipse.swt.SWT;importorg.ecli