當前位置: 首頁>>代碼示例>>Java>>正文


Java ColorDialog類代碼示例

本文整理匯總了Java中org.eclipse.swt.widgets.ColorDialog的典型用法代碼示例。如果您正苦於以下問題:Java ColorDialog類的具體用法?Java ColorDialog怎麽用?Java ColorDialog使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ColorDialog類屬於org.eclipse.swt.widgets包,在下文中一共展示了ColorDialog類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addSelectionListeneronButton

import org.eclipse.swt.widgets.ColorDialog; //導入依賴的package包/類
private void addSelectionListeneronButton(Button button, TableEditor editor) {
	button.addSelectionListener(new SelectionAdapter() {

		@Override
		public void widgetSelected(SelectionEvent e) {
			ColorDialog dlg = new ColorDialog(Display.getCurrent().getActiveShell());
			dlg.setRGB(new RGB(0, 0, 0));
			RGB rgb = dlg.open();
			if (rgb != null) {
				Color color = new Color(shell.getDisplay(), rgb);
				String colorValue = convertRGBToHEX(rgb);
				editor.getItem().setText(1, colorValue);
				color.dispose();
			}
		}
	});
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:18,代碼來源:HeaderAndDataFormattingDialog.java

示例2: addListeners

import org.eclipse.swt.widgets.ColorDialog; //導入依賴的package包/類
private void addListeners(){
	this.button.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent event) {
			ColorDialog dlg = new ColorDialog(ButtonColor.this.button.getShell());
			dlg.setRGB(ButtonColor.this.value);
			dlg.setText(TuxGuitar.getProperty("choose-color"));
			RGB result = dlg.open();
			if (result != null) {
				ButtonColor.this.loadColor(result);
			}
		}
	});
	this.button.addDisposeListener(new DisposeListener() {
		public void widgetDisposed(DisposeEvent e) {
			ButtonColor.this.disposeColor();
		}
	});
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:19,代碼來源:TGMatrixConfig.java

示例3: addListeners

import org.eclipse.swt.widgets.ColorDialog; //導入依賴的package包/類
private void addListeners(){
	this.button.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent event) {
			if(StylesOption.this.initialized){
				ColorDialog dlg = new ColorDialog(getShell());
				dlg.setRGB(ButtonColor.this.value);
				dlg.setText(TuxGuitar.getProperty("choose-color"));
				RGB result = dlg.open();
				if (result != null) {
					ButtonColor.this.loadColor(result);
				}
			}
		}
	});
	this.button.addDisposeListener(new DisposeListener() {
		public void widgetDisposed(DisposeEvent e) {
			ButtonColor.this.disposeColor();
		}
	});
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:21,代碼來源:StylesOption.java

示例4: editColor

import org.eclipse.swt.widgets.ColorDialog; //導入依賴的package包/類
/**
 * Opens a dialog to change the color.
 *
 * @param color
 *          the color to change
 * @return the changed color
 */
public static String editColor(Diagram diagram, String colorStr) {
  Color color = null;
  if (colorStr == null) {
    color = Graphiti.getGaService().manageColor(diagram, IColorConstant.BLACK);
  } else {
    color = EditorUtils.buildColorFromString(diagram, colorStr);
  }
  ColorDialog colorDialog = new ColorDialog(Display.getDefault().getActiveShell());
  colorDialog.setText("Choose color");
  colorDialog.setRGB(new RGB(color.getRed(), color.getGreen(), color.getBlue()));

  RGB retRgb = colorDialog.open();
  if (retRgb == null) {
    return colorStr;
  } else {
    return EditorUtils.toString(retRgb);
  }
}
 
開發者ID:eclipse,項目名稱:triquetrum,代碼行數:26,代碼來源:EditorUtils.java

示例5: editColor

import org.eclipse.swt.widgets.ColorDialog; //導入依賴的package包/類
/**
 * Opens a dialog to change the color.
 * 
 * @param color
 *            the color to change
 * @return the changed color
 */
public static Color editColor(Color color) {
	if (color != null && color.eContainer() instanceof Diagram) {
		Shell shell = getShell();
		ColorDialog colorDialog = new ColorDialog(shell);
		colorDialog.setText("Choose Color");
		colorDialog.setRGB(new RGB(color.getRed(), color.getGreen(), color.getBlue()));

		RGB retRgb = colorDialog.open();
		if (retRgb == null) {
			return null;
		}

		Diagram diagram = (Diagram) color.eContainer();
		Color newColor = Graphiti.getGaService().manageColor(diagram, retRgb.red, retRgb.green, retRgb.blue);
		return newColor;

	}

	return null;
}
 
開發者ID:logicalhacking,項目名稱:SecureBPMN,代碼行數:28,代碼來源:SampleUtil.java

示例6: mouseDoubleClick

import org.eclipse.swt.widgets.ColorDialog; //導入依賴的package包/類
@Override
public void mouseDoubleClick(final MouseEvent e) {
	final int x = e.x + boxText.getHorizontalPixel();
	final int y = e.y + boxText.getTopPixel();

	int level = -1;
	for (final Box b : visibleBoxes()) {
		if (contains(b.rec, x, y)) {
			if (level < b.level) {
				level = b.level;
			}
		}
	}
	level++;

	final ColorDialog colorDialog = new ColorDialog(boxText.getShell());
	final Color oldColor1 = settings.getColor(level);
	if (oldColor1 != null) {
		colorDialog.setRGB(oldColor1.getRGB());
	}

	settings.setColor(level, colorDialog.open());
}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:24,代碼來源:BoxDecoratorImpl.java

示例7: ColorPicker

import org.eclipse.swt.widgets.ColorDialog; //導入依賴的package包/類
public ColorPicker(Composite parent, final Color originalColor) {
    super(parent, SWT.SHADOW_OUT);
    if (originalColor == null) throw new IllegalArgumentException("null");
    this.selectedColor = originalColor;
    setImage(getColorImage(originalColor));
    addMouseListener(
            new MouseAdapter() {
                @Override
                public void mouseDown(MouseEvent e) {
                    ColorDialog dialog = new ColorDialog(new Shell(Display.getDefault(), SWT.SHELL_TRIM));
                    dialog.setRGB(selectedColor.getRGB());
                    RGB selected = dialog.open();
                    if (selected != null) {
                        update(selected);
                    }
                }
            });
}
 
開發者ID:heartsome,項目名稱:translationstudio8,代碼行數:19,代碼來源:ColorPicker.java

示例8: open

import org.eclipse.swt.widgets.ColorDialog; //導入依賴的package包/類
/**
 * Activate the editor for this selector. This causes the color selection
 * dialog to appear and wait for user input.
 * 
 * @since 3.2
 */
public void open() {
	ColorDialog colorDialog = new ColorDialog(fButton.getShell());
	colorDialog.setRGB(fColorValue);
	RGB newColor = colorDialog.open();
	if (newColor != null) {
	    RGB oldValue = fColorValue;
	    fColorValue = newColor;
	    final Object[] finalListeners = getListeners();
	    if (finalListeners.length > 0) {
	        PropertyChangeEvent pEvent = new PropertyChangeEvent(
	                this, PROP_COLORCHANGE, oldValue, newColor);
	        for (int i = 0; i < finalListeners.length; ++i) {
	            IPropertyChangeListener listener = (IPropertyChangeListener) finalListeners[i];
	            listener.propertyChange(pEvent);
	        }
	    }
	    updateColorImage();
	}
}
 
開發者ID:ghillairet,項目名稱:gef-gwt,代碼行數:26,代碼來源:ColorSelector.java

示例9: selectColor

import org.eclipse.swt.widgets.ColorDialog; //導入依賴的package包/類
/**
 * Open up a widget color wheel with the specified title.
 * Should be platform specific.
 * the specified integer should be in the following format.
 * lowest order 8 bits red
 * middle order 8 bits green
 * highest order 8 bits blue
 * ie: xxxxxxxx xxxxxxxx  xxxxxxxx
 *     BLUE     GREEN     RED
 */
public Integer selectColor(int oldColor, String dialogTitle)
{
    RGB old = GraphicsUtil.getRGBFromColor(oldColor);

    // Open the platform specific color chooser
    ColorDialog dialog = new ColorDialog(window);
    dialog.setRGB(old);
    if (dialogTitle != null)
    {
        dialog.setText(dialogTitle);
    }
    RGB newColor = dialog.open();

    if (newColor != null) {
        return new Integer(GraphicsUtil.getColorFromRGB(newColor));
    }

    return null;
}
 
開發者ID:cogtool,項目名稱:cogtool,代碼行數:30,代碼來源:DefaultInteraction.java

示例10: changeBackgroundColor

import org.eclipse.swt.widgets.ColorDialog; //導入依賴的package包/類
public void changeBackgroundColor() {
	ColorDialog cd = new ColorDialog(getShell());
	cd.setRGB(text.getBackground().getRGB());
	cd.setText("Choose a color");

	RGB newColor = cd.open();
	if (newColor != null)
		Config.getInstance().setValue(Config.BACKGROUND_COLOR,
				new Color(Display.getCurrent(), newColor));
	updateFont();
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:12,代碼來源:EditingPane.java

示例11: changeFontColor

import org.eclipse.swt.widgets.ColorDialog; //導入依賴的package包/類
public void changeFontColor() {
	ColorDialog cd = new ColorDialog(getShell());
	cd.setRGB(text.getBackground().getRGB());
	cd.setText("Choose a color");

	RGB newColor = cd.open();
	if (newColor != null)
		Config.getInstance().setValue(Config.FONT_COLOR,
				new Color(Display.getCurrent(), newColor));
	updateFont();
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:12,代碼來源:EditingPane.java

示例12: pickColor

import org.eclipse.swt.widgets.ColorDialog; //導入依賴的package包/類
/**
 * Opens a dialog to let the user pick a color.
 *
 * @param shell
 *        the shell on which to open the dialog (must not be
 *        <code>null</code>)
 * @param initialColor
 *        the initial color to set in the dialog, or <code>null</code> to
 *        use the dialog default
 * @return the color the user picked, or <code>null</code> if the dialog was
 *         cancelled
 */
public String pickColor(final Shell shell, final RGB initialColor) {
    Check.notNull(shell, "shell"); //$NON-NLS-1$

    /*
     * Mac OS X is Extremely Weird Here!
     *
     * On Mac OS X, we open the ColorDialog and it's automatically hooked
     * into the selection in Safari! Changing colors in the dialog while
     * it's open immediately changes the color in the document, before the
     * dialog even closes (we're blocking in this method). We always get
     * null back from dialog.open() when the dialog is closed, so we don't
     * set anything in the document, but that's OK because Safari is
     * magically updating its document for us. Very weird!
     */

    final ColorDialog dialog = new ColorDialog(shell);

    if (initialColor != null) {
        dialog.setRGB(initialColor);
    }

    final RGB rgb = dialog.open();
    if (rgb != null) {
        return String.format("#%1$02x%2$02x%3$02x", rgb.red, rgb.green, rgb.blue); //$NON-NLS-1$
    }
    return null;
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:40,代碼來源:HTMLEditor.java

示例13: updatePropertyFromWidget

import org.eclipse.swt.widgets.ColorDialog; //導入依賴的package包/類
private void updatePropertyFromWidget() {
	ColorDialog cd = new ColorDialog(Display.getCurrent().getActiveShell());
	cd.setText("Choose color");
	cd.setRGB(getValueOfProperty().getRGB());
	RGB newColor = cd.open();
	if (newColor == null)
		return;
			
	try {
		BeanUtils.setProperty(bean, property, Colors.createColor(newColor));
	} catch (IllegalAccessException | InvocationTargetException e) {
		throw new RuntimeException(e);
	}	
}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:15,代碼來源:BindColorToButtonListener.java

示例14: openDialogBox

import org.eclipse.swt.widgets.ColorDialog; //導入依賴的package包/類
protected Object openDialogBox(Control cellEditorWindow) {
	ColorDialog dialog = new ColorDialog(cellEditorWindow.getShell());
       Object value = getValue();
       if (value != null) {
		dialog.setRGB((RGB) value);
	}
       value = dialog.open();
       RGB rgb = dialog.getRGB();//return the same if cancelled
       if (rgb != null){
       	return rgb;//rgbToString(rgb);
       }
       return null;
}
 
開發者ID:ShoukriKattan,項目名稱:ForgedUI-Eclipse,代碼行數:14,代碼來源:ColorCellEditor2.java

示例15: doChangeColor

import org.eclipse.swt.widgets.ColorDialog; //導入依賴的package包/類
protected static void doChangeColor(Shell s) {
	// TODO Auto-generated method stub
	ColorDialog d = new ColorDialog(s, SWT.PRIMARY_MODAL);
	RGB rgb = d.open();
	System.out.println(rgb.toString());
	if (null != rgb) {
		Color c = SWTResourceManager.getColor(rgb);
		backColortarget = c;
		PropertiesUtil.setProperty("rgbRed", backColortarget.getRed() + "");
		PropertiesUtil.setProperty("rgbGree", backColortarget.getGreen() + "");
		PropertiesUtil.setProperty("rgbBlue", backColortarget.getBlue() + "");
		if (null != compList && compList.size() > 0) {
			for (Composite cd : compList) {
				cd.setBackground(c);
				Control[] cts = cd.getChildren();
				if (cts.length > 0) {
					for (Control cs : cts) {
						if (cs instanceof CLabel) {
							cs.setBackground(c);
						}
					}
				}
			}
		}
	}

}
 
開發者ID:YelaSeamless,項目名稱:swtUI4,代碼行數:28,代碼來源:LayoutUtils.java


注:本文中的org.eclipse.swt.widgets.ColorDialog類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。