Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Label

Posted on 2004-03-30
4
Medium Priority
?
269 Views
Last Modified: 2010-03-31
Hi guys

How do you manipulate the Label that is on a panel? I mean how can you bold and change the size of a Label that is on a panel?
0
Comment
Question by:krizmotlhala
4 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 10716411
>>I mean how can you bold

Set the font

yourLabel.setFont(new Font("sanserif", Font.BOLD, 12));

>>and change the size of a Label...

That depends on its context...
0
 
LVL 30

Assisted Solution

by:GrandSchtroumpf
GrandSchtroumpf earned 500 total points
ID: 10716976
you can use the getFont method, get the font attributes and use these attributes to build your new font.  

    Font myFont = myLabel.getFont();
    Map myMap = myFont.getAttributes();
    myMap.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD); // bold font
    Float myFloat = (Float)myMap.get(TextAttribute.SIZE);
    Float newFloat = new Float (myFloat.floatValue() + 2); // increasing the size
    myMap.put(TextAttribute.SIZE, newFloat);
    myLabel.setFont(new Font(myMap));
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

916 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