List of usage examples for org.eclipse.swt.widgets Label Label
public Label(Composite parent, int style)
From source file:ViewFormExample.java
public ViewFormExample() { shell.setLayout(new FillLayout()); final ViewForm viewForm = new ViewForm(shell, SWT.BORDER); Label label = new Label(viewForm, SWT.NULL); label.setText("Top center"); viewForm.setTopCenter(label);/*from w ww . j a va2 s .com*/ shell.setSize(400, 200); shell.open(); //textUser.forceFocus(); // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in event queue display.sleep(); } } display.dispose(); }
From source file:GroupExamples.java
public GroupExamples() { Group group0 = new Group(shell, SWT.NULL); group0.setLayout(new FillLayout()); Label label = new Label(group0, SWT.NULL); label.setAlignment(SWT.CENTER);//from w w w . ja v a2s .c o m 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(10, 10 + i * 50, 300, 40); } shell.pack(); shell.open(); //textUser.forceFocus(); // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in event queue display.sleep(); } } display.dispose(); }
From source file:SWTMenuExample.java
public SWTMenuExample() { display = new Display(); shell = new Shell(display); shell.setText("Menu Example"); shell.setSize(300, 200);/* ww w. ja v a 2 s.c o m*/ label = new Label(shell, SWT.CENTER); label.setBounds(shell.getClientArea()); menuBar = new Menu(shell, SWT.BAR); fileMenuHeader = new MenuItem(menuBar, SWT.CASCADE); fileMenuHeader.setText("&File"); fileMenu = new Menu(shell, SWT.DROP_DOWN); fileMenuHeader.setMenu(fileMenu); fileSaveItem = new MenuItem(fileMenu, SWT.PUSH); fileSaveItem.setText("&Save"); fileExitItem = new MenuItem(fileMenu, SWT.PUSH); fileExitItem.setText("E&xit"); helpMenuHeader = new MenuItem(menuBar, SWT.CASCADE); helpMenuHeader.setText("&Help"); helpMenu = new Menu(shell, SWT.DROP_DOWN); helpMenuHeader.setMenu(helpMenu); helpGetHelpItem = new MenuItem(helpMenu, SWT.PUSH); helpGetHelpItem.setText("&Get Help"); fileExitItem.addSelectionListener(new fileExitItemListener()); fileSaveItem.addSelectionListener(new fileSaveItemListener()); helpGetHelpItem.addSelectionListener(new helpGetHelpItemListener()); shell.setMenuBar(menuBar); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:HelloWorld.java
/** * Creates the main window's contents// ww w. ja v a 2s. c om * * @param parent the main window * @return Control */ protected Control createContents(Composite parent) { // Create a Hello, World label Label label = new Label(parent, SWT.CENTER); label.setText("Hello, World"); return label; }
From source file:HelloWorld3.java
public Shell open(Display display) { final Shell shell = new Shell(display); final Label label = new Label(shell, SWT.CENTER); label.setText("Hello_world"); label.pack();/*from ww w . j ava 2 s. c o m*/ shell.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { label.setBounds(shell.getClientArea()); } }); shell.pack(); shell.open(); return shell; }
From source file:SingleMultiLists.java
public SingleMultiLists() { init();/*from w w w.j a va2 s . co m*/ GridLayout gridLayout = new GridLayout(2, true); shell.setLayout(gridLayout); (new Label(shell, SWT.NULL)).setText("SINGLE"); (new Label(shell, SWT.NULL)).setText("MULTI"); List singleSelectList = new List(shell, SWT.BORDER); List mutliSelectList = new List(shell, SWT.MULTI | SWT.BORDER); String[] items = new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }; for (int i = 0; i < items.length; i++) { singleSelectList.add(items[i]); mutliSelectList.add(items[i]); } shell.pack(); shell.open(); //textUser.forceFocus(); // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in event queue display.sleep(); } } display.dispose(); }
From source file:LabelSeparator.java
public LabelSeparator() { init();/*w ww .j a v a2 s. c o m*/ // shell.setLayout(new RowLayout()); Label label = new Label(shell, SWT.BORDER); // Label label = new Label(shell, SWT.SEPARATOR); label.setImage(image); label.setText("Label"); label.setBounds(10, 10, 150, 150); CLabel clabel = new CLabel(shell, SWT.SHADOW_IN); clabel.setImage(image); clabel.setText("CLabel"); clabel.setBounds(170, 10, 150, 150); shell.pack(); shell.open(); //textUser.forceFocus(); // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in event queue display.sleep(); } } display.dispose(); }
From source file:RadioButtons.java
public RadioButtons() { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Label label = new Label(shell, SWT.NULL); label.setText("Gender: "); label.setBackground(display.getSystemColor(SWT.COLOR_YELLOW)); Button femaleButton = new Button(shell, SWT.RADIO); femaleButton.setText("F"); Button maleButton = new Button(shell, SWT.RADIO); maleButton.setText("M"); label = new Label(shell, SWT.NULL); label.setText(" Title: "); label.setBackground(display.getSystemColor(SWT.COLOR_YELLOW)); Composite composite = new Composite(shell, SWT.NULL); composite.setLayout(new RowLayout()); Button mrButton = new Button(composite, SWT.RADIO); mrButton.setText("Mr."); Button mrsButton = new Button(composite, SWT.RADIO); mrsButton.setText("Mrs."); Button msButton = new Button(composite, SWT.RADIO); msButton.setText("Ms."); Button drButton = new Button(composite, SWT.RADIO); drButton.setText("Dr."); shell.pack();/*from w w w. j av a 2 s . c o m*/ shell.open(); //textUser.forceFocus(); // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in event queue display.sleep(); } } display.dispose(); }
From source file:ShowInputDialog.java
private void createContents(final Shell parent) { parent.setLayout(new FillLayout(SWT.VERTICAL)); final Label label = new Label(parent, SWT.NONE); Button button = new Button(parent, SWT.PUSH); button.setText("Push Me"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Create and display the InputDialog InputDialog dlg = new InputDialog(parent); String input = dlg.open(); if (input != null) { // User clicked OK; set the text into the label label.setText(input);//w w w. ja v a2 s .co m label.getParent().pack(); } } }); }
From source file:ScaleExample.java
public ScaleExample() { shell.setLayout(new GridLayout(1, true)); Label label = new Label(shell, SWT.NULL); label.setText("Volume:"); scale = new Scale(shell, SWT.VERTICAL); scale.setBounds(0, 0, 40, 200);//from w w w . j a v a2s . co m scale.setMaximum(20); scale.setMinimum(0); scale.setIncrement(1); scale.setPageIncrement(5); scale.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { int perspectiveValue = scale.getMaximum() - scale.getSelection() + scale.getMinimum(); value.setText("Vol: " + perspectiveValue); } }); value = new Text(shell, SWT.BORDER | SWT.SINGLE); value.setEditable(false); scale.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); value.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); shell.pack(); shell.open(); //textUser.forceFocus(); // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in event queue display.sleep(); } } display.dispose(); }