Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!
  • 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
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

JFrame help

 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 27586
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
No one can make you feel inferior without your consent - Eleanor Roosevelt. tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic