Fonts

How do i change the font to something else?
[50 byte] By [ichbinsterbena] at [2007-11-27 3:22:42]
# 1
x.setFont(somethingElse);
jTooheya at 2007-7-12 8:25:27 > top of Java-index,Java Essentials,New To Java...
# 2
> How do i change the font to something else?On what? Where? Do you think we can read your mind?Kaj
kajbja at 2007-7-12 8:25:27 > top of Java-index,Java Essentials,New To Java...
# 3
i want to set a label's font to something else.Message was edited by: ichbinsterben
ichbinsterbena at 2007-7-12 8:25:27 > top of Java-index,Java Essentials,New To Java...
# 4
too slow... :(Message was edited by: hunter9000
hunter9000a at 2007-7-12 8:25:27 > top of Java-index,Java Essentials,New To Java...
# 5
aLabel.setFont(somethingElse);
jTooheya at 2007-7-12 8:25:27 > top of Java-index,Java Essentials,New To Java...
# 6
> i want to set a label's font to something else.> > Message was edited by: > ichbinsterbenSee reply #1 and the javadoc for JLabel and FontKaj
kajbja at 2007-7-12 8:25:27 > top of Java-index,Java Essentials,New To Java...
# 7
it doesn't work, do i need quotes or do i need something with it?Message was edited by: ichbinsterben
ichbinsterbena at 2007-7-12 8:25:27 > top of Java-index,Java Essentials,New To Java...
# 8
> it doesn't work, do i need quotes or do i need> something with it?> > Message was edited by: > ichbinsterbenPost the error message, it's still impossible for us to read your mind.
kajbja at 2007-7-12 8:25:27 > top of Java-index,Java Essentials,New To Java...
# 9

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class Title

{

JFrame f1;

JPanel p1;

JLabel Storys;

Container c1;

boolean end;

public Title()

{

f1 = new JFrame("HOBO");

f1.setSize(750,650);

c1 = f1.getContentPane();

p1 = new JPanel();

end = false;

JPanel Story = new JPanel(new GridLayout(35,1));

Story.setBackground(Color.white);

Story.setFont("CG Times");

Story.add(new JLabel(""));

Story.add(new JLabel(""));

Story.add(new JLabel(""));

Story.add(new JLabel(""));

Story.add(new JLabel(""));

Story.add(new JLabel(""));

Story.add(new JLabel(""));

Story.add(new JLabel("This is Hogan. Hogan is homeless."));

Story.add(new JLabel("To be more specific, he's a hobo."));

Story.add(new JLabel("He wanders around more than a bum, but"));

Story.add(new JLabel("he's dirtier than a drifter. The world"));

Story.add(new JLabel("has been changing, and the lifestyle has"));

Story.add(new JLabel("gotten a lot harder to stay alive."));

Story.add(new JLabel("Hogan even considered geting a job..."));

Story.add(new JLabel("His luck made a turn for the better. While"));

Story.add(new JLabel("he was filling out a Wal*Mart application in the"));

Story.add(new JLabel("dumpster behind the store, when he heard of the"));

Story.add(new JLabel("Magical Soup Kitchen, with meat in the soup and"));

Story.add(new JLabel("spoons to eat the soup with. It was like "));

Story.add(new JLabel("Vahaula, only with mor stabbings. It was supposed to be"));

Story.add(new JLabel("a legend, but it looked so real. "));

Story.add(new JLabel("being a curious hobo he went in the Magical Soup Kitchen"));

Story.add(new JLabel("and was awed with amazement. A waiter came up to him and"));

Story.add(new JLabel("had asked if he were homeless or not"));

Story.add(new JLabel("\"Of course\" he said with confidence"));

Story.add(new JLabel(""));

Story.add(new JLabel(""));

Story.add(new JLabel(""));

Story.add(new JLabel(""));

Story.add(new JLabel(""));

Story.add(new JLabel("Press Enter..."));

p1.add(Story);

c1.add(p1);

f1.show();

}

}

the message is

"cannot find symbol - method .setFont(java.lang.String"

Message was edited by:

ichbinsterben

ichbinsterbena at 2007-7-12 8:25:27 > top of Java-index,Java Essentials,New To Java...
# 10
Font font = new Font(...);aLabel.setFont(font);
jTooheya at 2007-7-12 8:25:27 > top of Java-index,Java Essentials,New To Java...
# 11
> "cannot find symbol - method> .setFont(java.lang.String"That means that setFont doesn't take a string as argument. Take a look in the javadoc. It says that it takes a Font as argument. I told you to take a look there.Kaj
kajbja at 2007-7-12 8:25:27 > top of Java-index,Java Essentials,New To Java...
# 12
Font font = new Font(...);UIManager.put("Label.font", font);
jTooheya at 2007-7-12 8:25:27 > top of Java-index,Java Essentials,New To Java...
# 13
> Font font = new Font(...);> aLabel.setFont(font);i still get errors, i must be doing something wrong
ichbinsterbena at 2007-7-12 8:25:27 > top of Java-index,Java Essentials,New To Java...
# 14

> > Font font = new Font(...);

> > aLabel.setFont(font);

>

> i still get errors, i must be doing something wrong

Great. We have still not learnt how to read minds, but we are working on it. Why aren't you providing us with the error message when you say that something isn' working?

kajbja at 2007-7-12 8:25:27 > top of Java-index,Java Essentials,New To Java...
# 15
http://www.bluegrasslyrics.com/all_song.cfm-recordID=s29253.htm
jTooheya at 2007-7-21 20:45:26 > top of Java-index,Java Essentials,New To Java...
# 16

> > > Font font = new Font(...);

> > > aLabel.setFont(font);

> >

> > i still get errors, i must be doing something

> wrong

>

> Great. We have still not learnt how to read minds,

> but we are working on it. Why aren't you providing us

> with the error message when you say that something

> isn' working?

i told you already.

ichbinsterbena at 2007-7-21 20:45:26 > top of Java-index,Java Essentials,New To Java...
# 17

> > > > Font font = new Font(...);

> > > > aLabel.setFont(font);

> > >

> > > i still get errors, i must be doing something

> > wrong

> >

> > Great. We have still not learnt how to read minds,

> > but we are working on it. Why aren't you providing

> us

> > with the error message when you say that something

> > isn' working?

>

>

> i told you already.

I have in that case already given you the answer. See reply #11

kajbja at 2007-7-21 20:45:26 > top of Java-index,Java Essentials,New To Java...
# 18
Font font = new Font("Serif", Font.PLAIN, 12);
jTooheya at 2007-7-21 20:45:27 > top of Java-index,Java Essentials,New To Java...