Solved

Label

Posted on 2004-03-30
4
264 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

622 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