Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2005

Tip: Looking for answers? Try searching our database.

Extending JOptionPane the clean way

Thread view: 
Carsten Zerbst - 12 Jan 2005 15:37 GMT
Hello,

I want to have a dialog with additional display of details which only open
on request. To achieve this I could

* start from scratch. I have to reinvent all the work done in JOptionPane
again
* extend JOptionPane. But then I would have to extend BasicOptionPaneUI as
well, which will of course breaking the usage of 3d party plafs ....

How do you things like that ? The same problems occures often, e.g.
with a ComboBox with an Tree instead of a List ...

Bye, Carsten
Andrey Kuznetsov - 13 Jan 2005 23:38 GMT
> I want to have a dialog with additional display of details which only open
> on request. To achieve this I could
[quoted text clipped - 3 lines]
> * extend JOptionPane. But then I would have to extend BasicOptionPaneUI as
> well, which will of course breaking the usage of 3d party plafs ....

Carsten,

all you need is to pass appropriate components to
JOptionPane#showOptionDialog(
   Component parentComponent,
   Object message, String title, int optionType,
   int messageType, Icon icon,
   Object[] options, Object initialValue)

Javadoc says:
"options - an array of objects indicating the possible choices the user can
make;
if the objects are components, they are rendered properly;
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
non-String objects are rendered using their toString methods;
if this parameter is null, the options are determined by the Look and Feel."

Signature

Andrey Kuznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

Carsten Zerbst - 14 Jan 2005 13:23 GMT
Am Fri, 14 Jan 2005 00:38:10 +0100 schrieb Andrey Kuznetsov:

> all you need is to pass appropriate components to
> JOptionPane#showOptionDialog(
>    

This approach does not work. At least it's looking disgusting.
The documentation of BasicOptionPaneUI says about the layout

       ------------------  
       | i | message    |
       | c | message    |
       | o | message    |
       | n | message    |
       ------------------
       |     buttons    |
       |________________|

Which gives this with just a customized component as message

    -------------------------
       | i | message        |
       | c | message        |
       | o | message        |
       | n |             |
    |   | Show Detail [X]     |
    |   | Additional Details|
    |   |            |
       -------------------------
       |     buttons        |
       |_______________________|


Whereas I want to have something like this

       -------------------------
       | i | message       |
       | c | message        |
       | o | message        |
       | n | message        |
    -------------------------
    | Show Details [X]     |
    | Optional Detail View    |
    |            |
       -------------------------
       |     buttons        |
       |_______________________|

So one need a new line in the layout which is not possible with
BasicOptionPaneUI

Bye, Carsten


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.