|
| 1 | +/******************************************************************************* |
| 2 | + * Java2Script Pacemaker (http://j2s.sourceforge.net) |
| 3 | + * |
| 4 | + * Copyright (c) 2006 ognize.com and others. |
| 5 | + * All rights reserved. This program and the accompanying materials |
| 6 | + * are made available under the terms of the Eclipse Public License v1.0 |
| 7 | + * which accompanies this distribution, and is available at |
| 8 | + * http://www.eclipse.org/legal/epl-v10.html |
| 9 | + * |
| 10 | + * Contributors: |
| 11 | + * ognize.com - initial API and implementation |
| 12 | + *******************************************************************************/ |
| 13 | + |
| 14 | +package net.sf.j2s.test.swt.widgets; |
| 15 | + |
| 16 | +import org.eclipse.swt.SWT; |
| 17 | +import org.eclipse.swt.events.SelectionAdapter; |
| 18 | +import org.eclipse.swt.events.SelectionEvent; |
| 19 | +import org.eclipse.swt.graphics.RGB; |
| 20 | +import org.eclipse.swt.layout.FillLayout; |
| 21 | +import org.eclipse.swt.widgets.Button; |
| 22 | +import org.eclipse.swt.widgets.ColorDialog; |
| 23 | +import org.eclipse.swt.widgets.Display; |
| 24 | +import org.eclipse.swt.widgets.Shell; |
| 25 | + |
| 26 | +public class TestColorDialog { |
| 27 | + |
| 28 | + /** |
| 29 | + * @param args |
| 30 | + */ |
| 31 | + public static void main(String[] args) { |
| 32 | + Display display = new Display(); |
| 33 | + final Shell shell = new Shell(display); |
| 34 | + shell.setLayout(new FillLayout()); |
| 35 | + Button button = new Button(shell, SWT.PUSH); |
| 36 | + button.addSelectionListener(new SelectionAdapter() { |
| 37 | + |
| 38 | + public void widgetSelected(SelectionEvent arg0) { |
| 39 | + System.out.println("Hello"); |
| 40 | + ColorDialog colorDialog = new ColorDialog(shell); |
| 41 | + //colorDialog.setRGB(new RGB(255, 0, 0)); |
| 42 | + RGB open = colorDialog.open(); |
| 43 | + System.out.println(open); |
| 44 | + } |
| 45 | + |
| 46 | + }); |
| 47 | + shell.open(); |
| 48 | + while (!shell.isDisposed()) |
| 49 | + if (!shell.getDisplay().readAndDispatch()) shell.getDisplay().sleep(); |
| 50 | + display.dispose(); |
| 51 | + } |
| 52 | + |
| 53 | +} |
0 commit comments