Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 23rd, 2005, 01:32 AM
Registered User
Join Date: Apr 2005
Location: , , Germany.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.

Reply With Quote
  #2 (permalink)  
Old 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.

Reply With Quote
  #3 (permalink)  
Old 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;


Reply With Quote
  #4 (permalink)  
Old 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.

 * 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);

        if(title != null)

        GridLayout gridLayout = new GridLayout(1, false);

        Composite content = new Composite(shell, SWT.NULL);
        content.setLayout(new RowLayout());

        GridData gridData = new GridData(GridData.FILL_HORIZONTAL);

        (new Label(content, SWT.NULL)).setText(message);
        final Text text = new Text(content, SWT.SINGLE | SWT.BORDER);
        if(initialValue != null)

        Composite buttons =new Composite(shell, SWT.NULL);

        gridData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);

        FillLayout fillLayout = new FillLayout();
        fillLayout.spacing = 5;

        final Button buttonOK = new Button(buttons, SWT.PUSH);
        final Button buttonCancel = new Button(buttons, SWT.PUSH);


        final class DialogSelectionListener implements SelectionListener {
            public String returnText;

            public void widgetSelected(SelectionEvent e) {
            public void widgetDefaultSelected(SelectionEvent e) {

            private void onSelected(Widget widget) {
                if(widget == buttonOK)
                    returnText = text.getText();

        DialogSelectionListener listener = new DialogSelectionListener();



        // 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 );


        // Set up the event loop.
        while (!shell.isDisposed()) {
            if (!shell.getDisplay().readAndDispatch()) {
                // If no more entries in event queue

        return listener.returnText;
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Viewer pushpa ASP.NET 1.0 and 1.1 Basics 2 April 13th, 2007 05:56 PM
Document viewer baburman General .NET 4 November 2nd, 2006 05:12 AM
fill dropdown list with items when parent list isaac_cm Pro PHP 1 July 10th, 2006 05:41 AM
List tablesname from database & list databasename ittorget MySQL 3 September 10th, 2005 03:06 AM
DLL Viewer qazi_nomi Classic ASP Professional 0 June 15th, 2004 06:25 AM

All times are GMT -4. The time now is 10:45 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.