List of usage examples for org.eclipse.swt.widgets Label setText
public void setText(String text)
From source file:PrintKTableExample.java
protected void createContents() { guiMainArea.setLayout(new FillLayout()); root = new Composite(guiMainArea, SWT.NONE); final GridLayout gridLayout = new GridLayout(); gridLayout.verticalSpacing = 10;/*from w w w .ja v a2 s .com*/ gridLayout.numColumns = 2; root.setLayout(gridLayout); { final Label l = new Label(root, SWT.NONE); l.setText("Papierformat:"); final GridData gridData_2 = new GridData(); gridData_2.widthHint = 80; l.setLayoutData(gridData_2); } { combFormat = new Combo(root, SWT.BORDER | SWT.READ_ONLY); combFormat.setToolTipText( "Bestimmt die PapiergroBe. Diese muss mit der Druckereinstellung ubereinstimmen."); for (int i = 0; i < formatNames.length; i++) { combFormat.add(formatNames[i]); } combFormat.setText(format); final GridData gridData_1 = new GridData(GridData.FILL_HORIZONTAL); gridData_1.widthHint = 180; combFormat.setLayoutData(gridData_1); } { final Label label = new Label(root, SWT.NONE); label.setText("Seitenrander:"); label.setLayoutData(new GridData(GridData.FILL_BOTH)); } { cmbMargin = new Combo(root, SWT.READ_ONLY); cmbMargin.setToolTipText("Bestimmt die Breite der Rander."); cmbMargin.add("Schmale Rander"); cmbMargin.add("Normale Rander"); cmbMargin.add("Breite Rander"); cmbMargin.select(marginStyle); cmbMargin.setLayoutData(new GridData(GridData.FILL_BOTH)); } { final Label label = new Label(root, SWT.NONE); final GridData gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); gridData.horizontalSpan = 1; label.setLayoutData(gridData); label.setText("Ausrichtung:"); } { butPortrait = new Button(root, SWT.RADIO); butPortrait.setToolTipText( "Bestimmt, ob das Papier hochkant oder Breit bedruckt werden soll. \nDiese Einstellung muss mit der des Druckers ubereinstimmen"); butPortrait.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); butPortrait.setText("Hochformat"); butPortrait.setSelection(portrait); } { final Label label = new Label(root, SWT.NONE); } { butLandscape = new Button(root, SWT.RADIO); butLandscape.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); butLandscape.setText("Breitformat"); butLandscape.setSelection(!portrait); butLandscape.setToolTipText( "Bestimmt, ob das Papier hochkant oder quer bedruckt werden soll. \nDiese Einstellung muss mit der des Druckers ubereinstimmen"); } { final Label label = new Label(root, SWT.NONE); label.setText("Skalierung:"); label.setLayoutData(new GridData(GridData.FILL_BOTH)); } { cmbScalierung = new Combo(root, SWT.READ_ONLY); cmbScalierung.setItems(scalings); cmbScalierung.select(10 - (scaling / 10)); cmbScalierung.setLayoutData(new GridData(GridData.FILL_BOTH)); cmbScalierung.setToolTipText( "Hiermit konnen Sie dir GroBe des Ausdrucks veringern, so daB mehr auf eine Seite passt."); } }
From source file:CustomControlExample.java
/** * Creates the "Example" widgets.//from w ww . j av a2 s. c om */ void createExampleWidgets() { /* Compute the widget style */ int style = getDefaultStyle(); if (borderButton.getSelection()) style |= SWT.BORDER; /* Create the example widgets */ try { link1 = new Link(linkGroup, style); link1.setText(ControlExample.getResourceString("LinkText")); } catch (SWTError e) { // temporary code for photon Label label = new Label(linkGroup, SWT.CENTER | SWT.WRAP); label.setText("Link widget not suported"); } }
From source file:CustomControlExample.java
/** * Creates the "StyledText Style" group. *///from w w w . ja va2 s. c o m void createStyledTextStyleGroup() { final Display display = controlGroup.getDisplay(); styledTextStyleGroup = new Group(controlGroup, SWT.NONE); styledTextStyleGroup.setText(ControlExample.getResourceString("StyledText_Styles")); styledTextStyleGroup.setLayout(new GridLayout(7, false)); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); data.horizontalSpan = 2; styledTextStyleGroup.setLayoutData(data); /* Get images */ boldImage = createBitmapImage(display, "bold"); italicImage = createBitmapImage(display, "italic"); redImage = createBitmapImage(display, "red"); yellowImage = createBitmapImage(display, "yellow"); underlineImage = createBitmapImage(display, "underline"); strikeoutImage = createBitmapImage(display, "strikeout"); /* Create controls to modify the StyledText */ Label label = new Label(styledTextStyleGroup, SWT.NONE); label.setText(ControlExample.getResourceString("StyledText_Style_Instructions")); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 7; label.setLayoutData(data); new Label(styledTextStyleGroup, SWT.NONE).setText(ControlExample.getResourceString("Bold")); boldButton = new Button(styledTextStyleGroup, SWT.PUSH); boldButton.setImage(boldImage); new Label(styledTextStyleGroup, SWT.NONE).setText(ControlExample.getResourceString("Underline")); underlineButton = new Button(styledTextStyleGroup, SWT.PUSH); underlineButton.setImage(underlineImage); new Label(styledTextStyleGroup, SWT.NONE).setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); new Label(styledTextStyleGroup, SWT.NONE).setText(ControlExample.getResourceString("Foreground_Style")); redButton = new Button(styledTextStyleGroup, SWT.PUSH); redButton.setImage(redImage); new Label(styledTextStyleGroup, SWT.NONE).setText(ControlExample.getResourceString("Italic")); italicButton = new Button(styledTextStyleGroup, SWT.PUSH); italicButton.setImage(italicImage); new Label(styledTextStyleGroup, SWT.NONE).setText(ControlExample.getResourceString("Strikeout")); strikeoutButton = new Button(styledTextStyleGroup, SWT.PUSH); strikeoutButton.setImage(strikeoutImage); new Label(styledTextStyleGroup, SWT.NONE).setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); new Label(styledTextStyleGroup, SWT.NONE).setText(ControlExample.getResourceString("Background_Style")); yellowButton = new Button(styledTextStyleGroup, SWT.PUSH); yellowButton.setImage(yellowImage); SelectionListener styleListener = new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Point sel = styledText.getSelectionRange(); if ((sel == null) || (sel.y == 0)) return; StyleRange style; for (int i = sel.x; i < sel.x + sel.y; i++) { StyleRange range = styledText.getStyleRangeAtOffset(i); if (range != null) { style = (StyleRange) range.clone(); style.start = i; style.length = 1; } else { style = new StyleRange(i, 1, null, null, SWT.NORMAL); } if (e.widget == boldButton) { style.fontStyle ^= SWT.BOLD; } else if (e.widget == italicButton) { style.fontStyle ^= SWT.ITALIC; } else if (e.widget == underlineButton) { style.underline = !style.underline; } else if (e.widget == strikeoutButton) { style.strikeout = !style.strikeout; } styledText.setStyleRange(style); } styledText.setSelectionRange(sel.x + sel.y, 0); } }; SelectionListener colorListener = new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Point sel = styledText.getSelectionRange(); if ((sel == null) || (sel.y == 0)) return; Color fg = null, bg = null; if (e.widget == redButton) { fg = display.getSystemColor(SWT.COLOR_RED); } else if (e.widget == yellowButton) { bg = display.getSystemColor(SWT.COLOR_YELLOW); } StyleRange style; for (int i = sel.x; i < sel.x + sel.y; i++) { StyleRange range = styledText.getStyleRangeAtOffset(i); if (range != null) { style = (StyleRange) range.clone(); style.start = i; style.length = 1; style.foreground = style.foreground != null ? null : fg; style.background = style.background != null ? null : bg; } else { style = new StyleRange(i, 1, fg, bg, SWT.NORMAL); } styledText.setStyleRange(style); } styledText.setSelectionRange(sel.x + sel.y, 0); } }; boldButton.addSelectionListener(styleListener); italicButton.addSelectionListener(styleListener); underlineButton.addSelectionListener(styleListener); strikeoutButton.addSelectionListener(styleListener); redButton.addSelectionListener(colorListener); yellowButton.addSelectionListener(colorListener); yellowButton.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { boldImage.dispose(); italicImage.dispose(); redImage.dispose(); yellowImage.dispose(); underlineImage.dispose(); strikeoutImage.dispose(); } }); }