Solved

JLabel Sizing

Posted on 2006-11-02
5
665 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This video teaches viewers about errors in exception handling.

730 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