label.setAlignment(SWT.CENTER); label.setImage(code);
@Override public void widgetSelected(SelectionEvent e) { if (currentText) { imageType.setEnabled(true); textType.setEnabled(false); if (text != null && !text.isDisposed()) { text.setVisible(false); text.dispose(); } label = new Label(grpValue, SWT.NONE); label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); label.setAlignment(SWT.CENTER); tranformImage(imageType, label); currentText = false; } } });
/** * Sets the alignment of the "Example" widgets. */ @Override void setExampleWidgetAlignment () { int alignment = 0; if (leftButton.getSelection ()) alignment = SWT.LEFT; if (centerButton.getSelection ()) alignment = SWT.CENTER; if (rightButton.getSelection ()) alignment = SWT.RIGHT; label1.setAlignment (alignment); label2.setAlignment (alignment); label3.setAlignment (alignment); label4.setAlignment (alignment); label5.setAlignment (alignment); label6.setAlignment (alignment); }
/** * Creates a label * * @param parent the parent composite * @param text the text of the label * @param widthHint the width, <0 to fill up the space * @param horizontalAlignment the horizontal alignment of the text * @param horizontalSpan the horizontal span * @param verticalSpan the vertical span * @return the label */ public static Label createLabel(Composite parent, String text, int widthHint, int horizontalAlignment, int horizontalSpan, int verticalSpan) { Label label = new Label(parent, SWT.NONE); GridData gridData = new GridData(SWT.FILL, (verticalSpan <= 1) ? SWT.CENTER : SWT.TOP, widthHint < 0, false, horizontalSpan, verticalSpan); if (widthHint >= 0) { gridData.widthHint = widthHint; } label.setLayoutData(gridData); label.setText(text); label.setAlignment(horizontalAlignment); return label; }
/** * Controls how text and images will be displayed in the receiver. * The argument should be one of <code>LEFT</code>, <code>RIGHT</code> * or <code>CENTER</code>. If the receiver is a <code>SEPARATOR</code> * label, the argument is ignored and the alignment is not changed. * * @param alignment the new alignment * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void setAlignment (int alignment) { checkWidget (); if ((style & SWT.SEPARATOR) != 0) return; if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return; style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER); style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER); setAlignment (); }
/** * Controls how text and images will be displayed in the receiver. * The argument should be one of <code>LEFT</code>, <code>RIGHT</code> * or <code>CENTER</code>. If the receiver is a <code>SEPARATOR</code> * label, the argument is ignored and the alignment is not changed. * * @param alignment the new alignment * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void setAlignment (int alignment) { checkWidget (); if ((style & SWT.SEPARATOR) != 0) return; if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return; style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER); style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER); setAlignment (); }
/** * Controls how text and images will be displayed in the receiver. * The argument should be one of <code>LEFT</code>, <code>RIGHT</code> * or <code>CENTER</code>. If the receiver is a <code>SEPARATOR</code> * label, the argument is ignored and the alignment is not changed. * * @param alignment the new alignment * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void setAlignment (int alignment) { checkWidget (); if ((style & SWT.SEPARATOR) != 0) return; if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return; style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER); style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER); setAlignment (); }
/** * Creates a label with an image * * @param parent the parent composite * @param image the image * @param widthHint the width, <0 to fill up the space * @param horizontalAlignment the horizontal alignment * @param verticalAlignment the vertical alignment * @param horizontalSpan the horizontal span * @param verticalSpan the vertical span * @return the label with an image */ public static Label createImage(Composite parent, Image image, int widthHint, int horizontalAlignment, int verticalAlignment, int horizontalSpan, int verticalSpan) { Label label = new Label(parent, SWT.NONE); GridData gridData = new GridData(horizontalAlignment, verticalAlignment, false, false, horizontalSpan, verticalSpan); if (widthHint >= 0) { gridData.widthHint = widthHint; } label.setAlignment(horizontalAlignment); label.setLayoutData(gridData); label.setImage(image); return label; }
/** * Add a empty label as a place holder */ private void addEmptyLabel(Composite parent){ Label emptyLabel = new Label(parent, 0); emptyLabel.setAlignment(SWT.LEFT); GridData statusData = new GridData(GridData.FILL_HORIZONTAL); emptyLabel.setFont(parent.getFont()); emptyLabel.setLayoutData(statusData); ((GridLayout)parent.getLayout()).numColumns++; }
String stringValue = value.getCssText().toLowerCase(); if ("left".equals(stringValue)){ label.setAlignment(SWT.LEFT); } else if ("lead".equals(stringValue)){ label.setAlignment(SWT.LEAD); } else if ("right".equals(stringValue)){ label.setAlignment(SWT.RIGHT); } else if ("trail".equals(stringValue)){ label.setAlignment(SWT.TRAIL); } else if ("center".equals(stringValue)){ label.setAlignment(SWT.CENTER); } else if ("inherit".equals(stringValue)) {
String stringValue = value.getCssText().toLowerCase(); if ("left".equals(stringValue)){ label.setAlignment(SWT.LEFT); } else if ("lead".equals(stringValue)){ label.setAlignment(SWT.LEAD); } else if ("right".equals(stringValue)){ label.setAlignment(SWT.RIGHT); } else if ("trail".equals(stringValue)){ label.setAlignment(SWT.TRAIL); } else if ("center".equals(stringValue)){ label.setAlignment(SWT.CENTER); } else if ("inherit".equals(stringValue)) {
/** * Creates an hint. * * @param parent the parent composite * @param text the text of the hint * @param widthHint the width, <0 to fill up the space * @param horizontalSpan the horizontal span * @param verticalSpan the vertical span * @return the label */ public static Label createHint(Composite parent, String text, int widthHint, int horizontalSpan, int verticalSpan) { Label label = createLabel(parent, text, widthHint, SWT.LEFT, horizontalSpan, verticalSpan); label.setAlignment(SWT.RIGHT); setItalicFont(parent.getDisplay(), label); return label; }
label.setAlignment( mLabelAlignment );
namesLabel.setAlignment(SWT.RIGHT);
img_label.setAlignment( SWT.CENTER ); gridData = new GridData( GridData.FILL_BOTH ); img_label.setLayoutData(gridData);
/** * Creates a label to display the link description when you hover over a * hyperlink. * * @param body */ private Label createHoverLabel(Composite body) { Label label = toolkit.createLabel(body, "", SWT.WRAP); //$NON-NLS-1$ String key = StringUtil.concat(rootPage.getId(), ".", "hover-text.fg"); //$NON-NLS-1$ //$NON-NLS-2$ Color fg = rootPageStyleManager.getColor(toolkit, key); if (fg == null) fg = toolkit.getColors().getColor(IFormColors.TITLE); label.setForeground(fg); label.setAlignment(SWT.CENTER); label.setFont(PageStyleManager.getBannerFont()); return label; }
versionHint.setAlignment(SWT.LEFT);
setFontDescription(defaultFont ().handle); setAlignment ();
setFontDescription(defaultFont ().handle); setAlignment ();
setFontDescription(defaultFont ().handle); setAlignment ();