final ColorPickerDialog d= new ColorPickerDialog(ActivityName.this,0xffffffff); d.setAlphaSliderVisible(true); d.setButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mPaint.setColor(d.getColor()); } }); d.setButton2("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); d.show();
public void dialogClosed(DialogClosedEvent event) { if (!event.isCanceled()) { colorTextBox.setValue(dlg.getColor().toUpperCase(), true); } } });
private void handleColorSelection(MouseEvent event, Button button, Input input) { final ColorPickerDialog dlg = new ColorPickerDialog(); dlg.getElement().getStyle().setZIndex(9999); dlg.addDialogClosedHandler(closedEvent -> { if (!closedEvent.isCanceled()) { int[] rgb = ColorUtils.getRGB(dlg.getColor()); String color = "#" + dlg.getColor(); input.setValue("rgb("+rgb[0]+","+rgb[1]+","+rgb[2]+");"); } }); dlg.showRelativeTo(ElementWrapperWidget.getWidget(button)); dlg.getElement().getStyle().setBackgroundColor("white"); }
private void handleColorSelection(MouseEvent event, Button button, Input input) { final ColorPickerDialog dlg = new ColorPickerDialog(); dlg.getElement().getStyle().setZIndex(9999); dlg.addDialogClosedHandler(closedEvent -> { if (!closedEvent.isCanceled()) { int[] rgb = ColorUtils.getRGB(dlg.getColor()); String color = "#" + dlg.getColor(); input.setValue("rgb("+rgb[0]+","+rgb[1]+","+rgb[2]+");"); } }); dlg.showRelativeTo(ElementWrapperWidget.getWidget(button)); dlg.getElement().getStyle().setBackgroundColor("white"); }
protected void showColorDialog(final UIObject owner) { if (readOnly) { return; } final ColorPickerDialog dlg = new ColorPickerDialog(); dlg.getElement().getStyle().setZIndex(9999); dlg.addDialogClosedHandler(event -> { if (!event.isCanceled()) { setValue("#" + dlg.getColor(), true); } }); String color = getValue(); if (color.startsWith("#")) { color = color.substring(1, color.length()); } dlg.setColor(color); dlg.showRelativeTo(owner); }