Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

setPreferredSize()

843805Apr 9 2007 — edited Apr 9 2007
Hello Pro's,
I have a JFrame in which there are a few JPanels and in the panels a few components. It works great but my problem is with the size of the JFrame, it covers up my whole screen and I am not able to see some of the components. I tried to fix the problem like this..
   public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Dimension d=Toolkit.getDefaultToolkit().getScreenSize();

                 JFrame frm = new AddressModule();
                 frm.setPreferredSize(new Dimension(300, 300));
                 new AddressModule().setVisible(true);
            }
        });
    }
The size of the JFrame still does not shrink to fit my screen. My screen resolution is 1024 x 768. Also, this application will be running on several other screens with different screen resolutions. How would I enable my application to change sizes based upon the user's screen resolution? Any suggestions would be greatly appreciated. Thanks in advance.

Misty.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 7 2007
Added on Apr 9 2007
8 comments
1,163 views