Solved

Label

Posted on 2004-03-30
4
257 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 125 total points
Comment Utility
>>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 125 total points
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 …
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 …

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now