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: Rezise JLabel when resizing window

  1. #1
    Join Date
    Apr 2013
    Thanked 0 Times in 0 Posts

    Default Rezise JLabel when resizing window


    I have a program that consist of a JFrame, and in that JFrame I have three JPanel-components. In one of these JPanels, j1, I'm using GridLayout(1,3). The components of that JPanel consist of two JLabels and one JPanel with the backround color of green. When I'm resizing (by width) the window the only component in j1 that's resizing is the green JPanel. How should I do to resize the JLabels also? Resize so that the text is adjusted by the width of the window.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Washington, DC
    My Mood
    Thanked 636 Times in 540 Posts

    Default Re: Rezise JLabel when resizing window

    Do you mean you want to change the font size based on the window width? You're going to have to do that manually. Check out the FontMetrics class.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Applet viewer window is diplaying in fron of the current window every time
    By jsreddy99 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 24th, 2013, 07:16 AM
  2. Replies: 2
    Last Post: August 27th, 2012, 09:19 PM
  3. Loop through JLabel and change JLabel
    By JoeBrown in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 11th, 2012, 12:52 PM
  4. Adding JLabel on other Jlabel
    By mike416 in forum AWT / Java Swing
    Replies: 3
    Last Post: March 29th, 2012, 11:50 AM
  5. Replies: 1
    Last Post: December 17th, 2011, 03:32 AM