Solved

JLabel Sizing

Posted on 2006-11-02
5
663 Views
Last Modified: 2008-02-26
I basically have an application in which I want to use Jlabels in as tiles.  I want to create a 4x4 grid of JLabels that contain one letter each.

ahdf
idus
ywnf
oapd

Something like that.  I have my labels rendering onto my window except I can't seem to change the size of the labels.  The Labels seem to stay the size of the letter no matter what size i specify with setSize.  I was wondering how I would go about making all of the labels squares.  Each square would have a letter in the middle and the blank space would be filled with a background color.

If anyone could help me out it would be greatly appreciated.


Thanks

~Matthew
0
Comment
Question by:Zeman4323
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
hoomanv earned 63 total points
ID: 17864498
Try setPrefferedSize() using null layout
or simply use GridLayout
0
 
LVL 2

Assisted Solution

by:glottis
glottis earned 62 total points
ID: 17864598
You can use the setPrefferedSize, with the functionality of setting the font size of your labels.

JLabel label = new JLabel("A");
label.setPrefferedSize(new Dimension(50, 50));
Font f = label.getFont();
f.setSize(<your preffered size of the font>); //i thing this is the method name
label.setFont(f);

regards,
0
 
LVL 14

Expert Comment

by:hoomanv
ID: 17864616
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jdbc error in jsp application 20 63
SHA2 certs for IIS AND Java? 2 113
maven disable workspace resolution 1 21
Eclipse Java import and method not resolved 4 48
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question