|
 |
BOOK: Professional Java Native Interfaces with SWT/JFace Discuss the book Professional Java Native Interfaces with SWT/JFace, by Jackwind Li Guojie, ISBN: 0-470-09459-1 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Professional Java Native Interfaces with SWT/JFace section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
|
 |
|
|
 |

April 23rd, 2005, 01:32 AM
|
Registered User
|
|
Join Date: Apr 2005
Location: , , Germany.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
List Viewer
The "SampleListViewer" in Chapter 7 wants to import the class "com.asprise.swt.OptionPane", but I can't find this.
Any Idea where to look?
I tried to look on the website that is given in some examples: http://www.asprise.com/swt
but this is also not reachable.
|

May 27th, 2005, 06:20 PM
|
Registered User
|
|
Join Date: May 2005
Location: Tucson, AZ, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
 I had the same experience. Also, no luck finding it on the aprise site.
Interesting book though.
|

May 27th, 2005, 11:03 PM
|
Registered User
|
|
Join Date: May 2005
Location: Tucson, AZ, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Perhaps something like the following would suffice:
public class OptionPane {
public static String showInputDialog(Shell parentShell, String dialogTitle, String dialogMessage, Object initialValue) {
boolean answer = MessageDialog.openQuestion(parentShell,dialogTitle ,dialogMessage);
String result = null;
if ( answer ) {
result = (String)initialValue;
}
return result;
}
}
|

December 7th, 2005, 10:46 PM
|
Registered User
|
|
Join Date: Dec 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi all
Below is the source code for OptionPane. http://www.asprise.com/swt is back now and you download the source code from it.
Sorry for any inconvenience caused.
Best regards.
Code:
/******************************************************************************
* All Right Reserved.
* Copyright (c) 1998, 2004 Jackwind Li Guojie
*
* Created on Feb 16, 2004 7:41:37 PM by JACK
* $Id$
*
*****************************************************************************/
package com.asprise.swt;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Widget;
/**
*
*/
public class OptionPane {
public static String showInputDialog(Shell parent, String message, String title, String initialValue) {
final Shell shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
//shell.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
if(title != null)
shell.setText(title);
GridLayout gridLayout = new GridLayout(1, false);
shell.setLayout(gridLayout);
Composite content = new Composite(shell, SWT.NULL);
content.setLayout(new RowLayout());
//content.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_CYAN));
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
content.setLayoutData(gridData);
(new Label(content, SWT.NULL)).setText(message);
final Text text = new Text(content, SWT.SINGLE | SWT.BORDER);
if(initialValue != null)
text.setText(initialValue);
Composite buttons =new Composite(shell, SWT.NULL);
gridData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
buttons.setLayoutData(gridData);
FillLayout fillLayout = new FillLayout();
fillLayout.spacing = 5;
buttons.setLayout(fillLayout);
final Button buttonOK = new Button(buttons, SWT.PUSH);
final Button buttonCancel = new Button(buttons, SWT.PUSH);
buttonOK.setText("OK");
buttonCancel.setText("Cancel");
final class DialogSelectionListener implements SelectionListener {
public String returnText;
public void widgetSelected(SelectionEvent e) {
onSelected(e.widget);
}
public void widgetDefaultSelected(SelectionEvent e) {
onSelected(e.widget);
}
private void onSelected(Widget widget) {
if(widget == buttonOK)
returnText = text.getText();
shell.dispose();
}
}
DialogSelectionListener listener = new DialogSelectionListener();
buttonCancel.addSelectionListener(listener);
buttonOK.addSelectionListener(listener);
shell.pack();
// Center the shell.
if(parent != null) {
Rectangle parentBounds = parent.getBounds();
Point shellSize = shell.getSize();
shell.setLocation( parentBounds.x+(parentBounds.width-shellSize.x)/2, parentBounds.y+(parentBounds.height-shellSize.y)/2 );
}
shell.open();
// Set up the event loop.
while (!shell.isDisposed()) {
if (!shell.getDisplay().readAndDispatch()) {
// If no more entries in event queue
shell.getDisplay().sleep();
}
}
return listener.returnText;
}
}
|
Thread Tools |
Search this Thread |
|
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |