• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

How to let a dialog be maximized

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have class that extends a non-modal JDialog box (the only way I could find to easily have an always-on-top window), and I'd like to add the ability to maximize it. Of course, I can add a button myself that will just make its dimensions the same as the screen, but I wondered if there was a solution that would let me have the normal OS-type maximize button in the title bar.

Thanks!
Tom
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the dialog set to be resizable (with Dialog.setResizable( true ))?

Brian
 
Tom McC
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian,

I tried explicity making it resizable to no avail; I can resize it fine, but no maximize button...it kind of makes sense that a dialog wouldn't be able to be maximized, but it doesn't make sense that I need to make a window a dialog just to get it to be on top :roll:

Thanks anyway---I'm ending up just making a button to maximize/restore the window myself.

Tom
 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Tom

Try the following code instead.
---------------
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
int screenHeight = screenSize.height;
int screenWidth = screenSize.width;

this.setSize(screenWidth, screenHeight);
 
Tom McC
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As an update, I did manage to find a class someone made to let a JFrame act in many ways like a modal dialog (with a maximize button!). This doesn't quite fit my purposes, as I only want the on-top functionality, not the modality, but I wanted to share the link:
Are you missing a maximize button on JDialog?


Thanks Pat, for the suggestion; this code works also, for anyone who's interested:
 
There's a way to do it better - find it. -Edison. A better tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic