Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JFrame help  RSS feed

 
Shashank Gokhale
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simple application where I display a JFrame. I want to maximize the JFrame size, so I have the code this.setExtendedState(MAXIMIZED_BOTH); in the constructor. How do I find the dimensions of this JFrame in its extended state though? I tried this.getSize().Height , this getSize().getHeight() and this.getHeight()? None of them work because they just return a value of 0. And what is the difference in all these statements in terms of what they do?
 
Rico Felix
Ranch Hand
Posts: 411
5
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can probably refer to the API documentation to find out more details about those methods.

There is this book that explains the swing API in detail which may also be of some help while programming GUI's using that framework: Filthy Rich Clients: Developing Animated and Graphical Effects for Desktop Java Applications
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't find out what the size of a component is until that component has been displayed on the screen.
 
Shashank Gokhale
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
paul chapman:

you're right!! I just had to move the getHeight() and getWidth() statements after the setVisible(true).
I thought initially that I could write the statements in any order, because if I wrote

setVisible(true);
setSize(100,200);

the frame still showed up with dimensions 100,200 even though the setSize was written after the setVisible.

Rico: thanks for the link


I am currently using Eclipse to write java code. But when I hover the mouse over any of the method names or keywords, I dont get a popup showing what that method or keyword does. I know Im supposed to so is there a way to inlude that documentation?

 
Chris Barrett
Bartender
Posts: 317
24
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shashank,

Within Eclipse, go to the Preferences menu and type 'hovers' in the search box. On the sidebar list you should see Java → Editor → Hovers. Within that menu you can control the hovers. The default should have "Combined Hover", "Externalized String", "Javadoc" and "Source" checked on.

Cheers!
Chris
 
Shashank Gokhale
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chris,

Yes they are checked. Is it possible that when Eclipse installed, the Javadocs or whatever is required did not install at the same time?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!