Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Label preferred size problem

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Thanked 0 Times in 0 Posts

    Default Label preferred size problem

    I am trying to set the width and height of my image (which is actually just a label with an icon) as the same as the width and height of my screen so that it can cover the entire frame.

    My code is:

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Dimension dim = toolkit.getScreenSize();
    menubkg.setPreferredSize(new Dimension(dim.width, dim.height));
    Unfortunately this doesn't actually seem to affect the width and height values of my label in the free design layout, and i need to use this layout so that i may place other images in the frame without being too restricted. I have tried placing this in the customized code section of my label, to no avail, aswell as the componentshow event.

    Any suggestions on what i might do/what i might be doing wrong?

  2. #2
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Thanked 206 Times in 182 Posts

    Default Re: Label preferred size problem

    Also at www.java-forums.org

Similar Threads

  1. [SOLVED] Need help with updating label
    By Neacel in forum AWT / Java Swing
    Replies: 5
    Last Post: January 22nd, 2012, 02:38 PM
  2. Label not showing up.
    By joshft91 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 1st, 2011, 03:36 PM
  3. Interaction between two label in animation
    By odiejodie in forum Java Theory & Questions
    Replies: 1
    Last Post: February 16th, 2011, 08:51 AM
  4. Limit File Size or Request Size
    By tarek.mostafa in forum Java Servlet
    Replies: 3
    Last Post: June 12th, 2010, 04:28 PM
  5. Limit File Size or Request Size
    By tarek.mostafa in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: June 11th, 2010, 07:21 AM