• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JDialog With Icon

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,
I have just created a Modal JDialog. When I run the program I see default program icon on the top-left hand corner.(Little icon). For example on Linux-KDE I see "K" as an icon. This works fine with JFrames using setImageIcon(...) method.
Question is how can we do that for JDialog if at all possible. or do we have to live with system default icon.
Please help.
Thanks in advance.
Nilesh
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It will use whatever the parent frame uses for an icon. JFileChooser works the same way.
 
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you need just basic dialogs, use JOptionPane.show######Dialog(). there are methods where you can specify the icon.If you need more complex dialogs, try the JOptionPane methods as well. you can trick a bit as the message is of type object, not String. this way I've been inserting combo boxes, for example.
chantal
 
NILESH PATEL
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your replies. But I have created a frame, say a wizrd box with about six tabbed pannes. Until now that frame was activated and worked with independantly. However due to overheads on the software I decided to make it modal, so user has to dispose one frame after finishing. This is where I get a problem. Using option pane you can create dialog and icons, but you are only limited to icons within content pane, but not next to string title of dialog/frame.
Is it correct? I think it is. But please comment on this and thanks again.
Nilesh
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry, I missed that point entirely in your posting.
Seems to me like you will have to extend JDialog to get the Icon into the frameborder.
chantal
 
NILESH PATEL
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,
I can do that, no problem with extending, but problem stays with JDialog itself. If we look at API of JDialog, it does not support IconImage methods, only frames and other components.
So extension of JDialog would not help, I Think....
However for timebeing what I have done is, I have passed a parent frame with icon to the current frame(to be modaled), Then setting contentpane of this dialog to be contentpane of the current frame. I think following should make this understand better.
1) Created a parent frame-A with some menus and buttons and so on, setting IconImage as well.
2) Created a JDialog with "new JDialog(frame-A);
3) Created another frame-B with tabbed panes, to be modaled.
4) Introduced a method called "void Display(JDialog)
5) Called this method from frame-A.
6) Replaced Contentpane of Dialog in Display() method, with contentpane of frame-B, usinf JDialog.setContentPane(...) method.
7) pack() and show() dialogs.
This really worked and also provided flexibility of using JFrame features in modal Dialog/Frame.
I think this is got to be the way round unles you guys can suggest better option. At least this works great.
Thanks again all, keep posting.
Nilesh
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic