Solved

Label

Posted on 2004-03-30
4
262 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
[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
4 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 125 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 125 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

Industry Leaders: 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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

749 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