SWT (JFace) group (Group display) _java programming

Source: Internet
Author: User
Tags pack sleep
Demo Code:
Copy Code code as follows:

Package swt_jface.demo9;
Import Org.eclipse.swt.SWT;
Import Org.eclipse.swt.layout.FillLayout;
Import Org.eclipse.swt.widgets.Display;
Import Org.eclipse.swt.widgets.Group;
Import Org.eclipse.swt.widgets.Label;
Import Org.eclipse.swt.widgets.Shell;
public class Groupexamples {

Display display = new display ();
Shell shell = new shell (display);
Public Groupexamples () {

Group group0 = new Group (shell, SWT. NULL);
Group0.setlayout (New Filllayout ());
Label label = new Label (GROUP0, SWT. NULL);
Label.setalignment (SWT. CENTER);
Label.settext ("a group without title.");

Group group1 = new Group (shell, SWT. NULL);
Group1.settext ("SWT.") NULL ");

Group group2 = new Group (shell, SWT. SHADOW_ETCHED_IN);
Group2.settext ("SWT.") Shadow_etched_in ");
Group Group3 = new Group (shell, SWT. Shadow_etched_out);
Group3.settext ("SWT.") Shadow_etched_out ");

Group GROUP4 = new Group (shell, SWT. SHADOW_IN);
Group4.settext ("SWT.") Shadow_in ");

Group GROUP5 = new Group (shell, SWT. Shadow_out);
Group5.settext ("SWT.") Shadow_out ");

group[] groups = new Group[]{group0, group1, group2, Group3, Group4, GROUP5};

for (int i=0; i<groups.length; i++) {
Groups[i].setbounds (Ten + i * 50, 300, 40);
}
Shell.pack ();
Shell.open ();

while (!shell.isdisposed ()) {
if (!display.readanddispatch ()) {
Display.sleep ();
}
}
Display.dispose ();
}
public static void Main (string[] args) {
New Groupexamples ();
}
}
Package swt_jface.demo9;
Import Org.eclipse.swt.SWT;
Import Org.eclipse.swt.layout.FillLayout;
Import Org.eclipse.swt.widgets.Display;
Import Org.eclipse.swt.widgets.Group;
Import Org.eclipse.swt.widgets.Label;
Import Org.eclipse.swt.widgets.Shell;
public class Groupexamples {

Display display = new display ();
Shell shell = new shell (display);
Public Groupexamples () {

Group group0 = new Group (shell, SWT. NULL);
Group0.setlayout (New Filllayout ());
Label label = new Label (GROUP0, SWT. NULL);
Label.setalignment (SWT. CENTER);
Label.settext ("a group without title.");

Group group1 = new Group (shell, SWT. NULL);
Group1.settext ("SWT.") NULL ");

Group group2 = new Group (shell, SWT. SHADOW_ETCHED_IN);
Group2.settext ("SWT.") Shadow_etched_in ");
Group Group3 = new Group (shell, SWT. Shadow_etched_out);
Group3.settext ("SWT.") Shadow_etched_out ");

Group GROUP4 = new Group (shell, SWT. SHADOW_IN);
Group4.settext ("SWT.") Shadow_in ");

Group GROUP5 = new Group (shell, SWT. Shadow_out);
Group5.settext ("SWT.") Shadow_out ");

group[] groups = new Group[]{group0, group1, group2, Group3, Group4, GROUP5};

for (int i=0; i<groups.length; i++) {
Groups[i].setbounds (Ten + i * 50, 300, 40);
}
Shell.pack ();
Shell.open ();

while (!shell.isdisposed ()) {
if (!display.readanddispatch ()) {
Display.sleep ();
}
}
Display.dispose ();
}
public static void Main (string[] args) {
New Groupexamples ();
}
}

Look at one more example:

Copy Code code as follows:

Package swt_jface.demo9;
Import Org.eclipse.swt.SWT;
Import Org.eclipse.swt.graphics.Image;
Import Org.eclipse.swt.layout.GridData;
Import Org.eclipse.swt.layout.GridLayout;
Import Org.eclipse.swt.widgets.Button;
Import Org.eclipse.swt.widgets.Combo;
Import Org.eclipse.swt.widgets.Display;
Import Org.eclipse.swt.widgets.Group;
Import Org.eclipse.swt.widgets.Label;
Import Org.eclipse.swt.widgets.Shell;
Import Org.eclipse.swt.widgets.Text;
public class Bugreport {

Display display = new display ();
Shell shell = new shell (display);
Public Bugreport () {

Shell.setlayout (New GridLayout (1, true));
Shell.setimage (New Image (Display, "c:/icons/bug.gif"));
Shell.settext ("Bug page");

Group Groupbug = new Group (shell, SWT. NULL);
Groupbug.settext ("Bug details");
Groupbug.setlayout (New GridLayout (2, false));
Groupbug.setlayoutdata (New Griddata (Griddata.fill_both));

New Label (Groupbug, SWT. NULL). SetText ("Priority");
Combo Combo = new Combo (Groupbug, SWT. BORDER);
Combo.setlayoutdata (New Griddata (griddata.fill_horizontal));

New Label (Groupbug, SWT. NULL). SetText ("Details");
Text text = new text (Groupbug, SWT. BORDER | Swt. MULTI);
Text.setlayoutdata (New Griddata (Griddata.fill_both));

Group Groupproxy = new Group (shell, SWT. NULL);
Groupproxy.settext ("Connection setting");
Groupproxy.setlayout (New GridLayout (2, false));
Groupproxy.setlayoutdata (New Griddata (griddata.fill_horizontal));

New Label (Groupproxy, SWT. NULL). SetText ("Proxy host");
Text Texthost = new text (Groupproxy, SWT. Single | Swt. BORDER);
Texthost.setlayoutdata (New Griddata (griddata.fill_horizontal));
New Label (Groupproxy, SWT. NULL). SetText ("Proxy port");
Text Textport = new text (Groupproxy, SWT. Single | Swt. BORDER);
Textport.setlayoutdata (New Griddata (griddata.fill_horizontal));

Button button = New button (Shell, SWT. PUSH);
Button.setlayoutdata (New Griddata (Griddata.horizontal_align_center));
Button.setalignment (SWT. CENTER);
Button.settext ("Submit bug");
Shell.pack ();
Shell.open ();

while (!shell.isdisposed ()) {
if (!display.readanddispatch ()) {
Display.sleep ();
}
}
Display.dispose ();
}
public static void Main (string[] args) {
New Bugreport ();
}
}

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.