Solved

JLabel Sizing

Posted on 2006-11-02
5
659 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
allswap challenge 6 99
Apps blocked by Java 9 79
diffSum example 4 37
Is Applet the way to go for my drag and drop system? 8 14
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

777 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