Hi guys,

This is me, novice programmer to Java.
i have a very simple question.

can i change Font of a Label?
for example i have a label:

Label l1 = new Label("Welcome To Java");

now what i want is to be able to change the text(Welcome to Java) to BOLD, ITALIC.

and another question:

i have used GridBagLayout in my applet program. so i have positioned all the components accordingly.
now assume my applet size is 300,300 and i would like to draw a string using paint method in the position 150,150.
if i maximum or resize the applet will the position of drawString change.

if yes, how to make it avoid changing.

thanks alot

Recommended Answers

All 2 Replies

Font for Label

Label label = new Label("Welcome To Java"); 
Font curFont = label.getFont();
label.setFont(new Font(curFont.getFontName(), Font.BOLD, 20));

About second question I'm not sure. Maybe somebody else can answer that

hey, thanks the font worked properly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.