SWT (JFace) experience sash (active control) _java programming

Source: Internet
Author: User
Tags sleep
The demo code is as follows:

Copy Code code as follows:

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 ();
}
}


One more example:

Copy Code code as follows:

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 ();
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.