Solved

Label

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Systems talking to each other 5 126
Non-recursive backtracking, using a stack 1 103
Java Jpanels and Jframe 8 28
Arrays.asList  VS  ArrayList 4 45
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…
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…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

863 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

25 Experts available now in Live!

Get 1:1 Help Now