演示代码如下:
复制代码代码如下:
paket 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;
contoh selempang kelas publik {
public static void main(String[] args) {
Tampilan tampilan = Tampilan baru();
Shell shell = Shell baru (tampilan);
selempang akhir selempang = selempang baru(shell, SWT.BORDER | SWT.VERTICAL);
selempang.setBounds(10, 10, 15, 60);
selempang.addListener(SWT.Selection, Pendengar baru() {
public void handleEvent(Acara e) {
System.out.println("Dipilih. ");
selempang.setBounds(ex, ey, e.width, e.height);
}
});
shell.open();
selempang.setFocus();
while (!shell.isDisposition()) {
jika (!display.readAndDispatch())
tampilan.tidur();
}
tampilan.buang();
}
}
paket 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;
contoh selempang kelas publik {
public static void main(String[] args) {
Tampilan tampilan = Tampilan baru();
Shell shell = Shell baru (tampilan);
selempang akhir selempang = selempang baru(shell, SWT.BORDER | SWT.VERTICAL);
selempang.setBounds(10, 10, 15, 60);
selempang.addListener(SWT.Selection, Pendengar baru() {
public void handleEvent(Acara e) {
System.out.println("Dipilih. ");
selempang.setBounds(ex, ey, e.width, e.height);
}
});
shell.open();
selempang.setFocus();
while (!shell.isDisposition()) {
jika (!display.readAndDispatch())
tampilan.tidur();
}
tampilan.buang();
}
}
再来一个例子:
复制代码代码如下:
paket 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.Teks;
kelas publik SashFormExample {
Tampilan tampilan = Tampilan baru();
Shell shell = Shell baru (tampilan);
Bentuk selempang;
SashForm selempangForm2;
contoh SashForm publik() {
shell.setLayout(FillLayout baru());
sashForm = new SashForm(kulit, SWT.HORIZONTAL);
Teks text1 = Teks baru (sashForm, SWT.CENTER);
text1.setText("Teks di panel #1");
Teks text2 = Teks baru (sashForm, SWT.CENTER);
text2.setText("Teks di panel #2");
sashForm2 = new SashForm(sashForm, SWT.VERTIKAL);
Label akhir labelA = Label baru(sashForm2, SWT.BORDER | SWT.CENTER);
labelA.setText("Label pada panel A");
Label akhir labelB = Label baru(sashForm2, SWT.BORDER |SWT.CENTER);
labelB.setText("Label pada panel B");
text1.addControlListener(ControlListener baru() {
public void controlMoved(ControlEvent e) {
}
public void controlResize(ControlEvent e) {
System.out.println("Ukuran Diubah");
//ArrayUtil.printArray(sashForm.getWeights(), System.out);
}
});
sashForm.setWeights(int baru[]{1, 2, 3});
labelA.addMouseListener(MouseListener baru() {
public void mouseDoubleClick(MouseEvent e) {
if(sashForm2.getMaximizedControl() == labelA)
selempangForm2.setMaximizedControl(null);
kalau tidak
selempangForm2.setMaximizedControl(labelA);
}
public void mouseDown(MouseEvent e) {
}
public void mouseUp(MouseEvent e) {
}
});
shell.setSize(450, 200);
shell.open();
while (!shell.isDisposition()) {
if (!display.readAndDispatch()) {
tampilan.tidur();
}
}
tampilan.buang();
}
public static void main(String[] args) {
Contoh SashForm baru();
}
}