• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

JFrame help

 
Ranch Hand
Posts: 103
  • 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?
 
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
 
Marshal
Posts: 24594
55
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: 103
  • 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?

 
Bartender
Posts: 322
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: 103
  • 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?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!