• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Minimum size on JDialogs?

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Does anyone know if there is a minimum size for JDialog that Swing itself enforces?

I am attempting to create a toolbar similar to one that you'd find in, say, Photoshop (the Photoshop tools palette, specifically). I want the width to be pretty narrow; like the Photoshop tools palette, it should be just two small buttons wide. When my toolbar is "docked", the width is just the way I want it. But when the user drags the toolbar away and it becomes floating, the width is too wide, despite my best efforts.

As an experiment, I also created a simple app with a JDialog, and set the JDialog's preferred, minimum, and maximum width to 20 pixels (IIRC, JToolbar uses a JDialog instance when it becomes floating). However, the JDialog still appeared much wider than that.

The same issue occurs for me in both Windows XP Java 5 and 6, and Mac OSX Java 5.

So does anyone know if Swing enforces a minimum size for JDialogs? And can anything be done about it?

Thanks in advance.
 
Sheriff
Posts: 22789
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it needs at least the width to show the title bar, and including the close button that's over 20 pixels it seems. You could try a JWindow but then you lose the title bar completely.
 
dave taubler
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the tip. It would probably mean digging into the JToolBar's ToolBarUI implementation to do something like that, but hey, I guess I'm up for the challenge.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you use
JDialog.setDefaultLookAndFeelDecorated(true);
and
dialog.setMinimumSize(new Dimension(0,0));

you can have any width you want
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic