• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trying to change font on a using bufferedwriter

 
Justin Char
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Font f = new Font("Lucida Sans Typewriter", Font.ITALIC, 48);

I tried the above didn't work said f isn't read.

Does anyone know what I am doing wrong.

J
 
Campbell Ritchie
Sheriff
Pie
Posts: 50277
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't used BufferedWriter for ages, so I can't remember whether you can change Fonts.

Try: Get a list of Fonts with GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts() which returns Font[]. Then iterate through the Font[] using for or for-each and System.out.println(f.getName());

That will confirm that you actually have that Font installed. I tried it a few minutes ago and I didn't have that Font, but I did have Lucida Sans Regular,
Lucida Sans Typewriter Bold, and Lucida Sans Typewriter Regular.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15495
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you explain the problem in more detail? What does this line of code have to do with BufferedWriter? What are you trying to achieve? Do you get a compiler error? If so, please copy and paste the exact error message.
 
Justin Char
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
strOut = ("TOTALS REPORT FOR TOTAL RCDS WITH NO UPDATES");
Counter.write(strOut);
Counter.newLine();
Counter.newLine();

I am getting no errors I just want to change the font and font size of the
My program works I just want to be able to adjust the fonts on my report.
("TOTALS REPORT FOR TOTAL RCDS WITH NO UPDATES");
//just want to change text to Courier New or something font size 24 or 48 anything.
 
Justin Char
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ritchie can you give me an example of how you would lay that out in a class.


Thanks, I don't know how to layout your suggestion in a class
 
Campbell Ritchie
Sheriff
Pie
Posts: 50277
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No
 
Campbell Ritchie
Sheriff
Pie
Posts: 50277
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and I still don't understand what Fonts have to do with BufferedWriters; it doesn't seem possible to change Fonts on BufferedWriters. The Font class is used to format text displayed on Swing (or AWT) text components which accept Fonts. See java.awt.Component.setFont() and java.awt.Graphics.setFont().
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15495
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A BufferedWriter writes plain text to an output stream (for example to a text file). A plain text file contains only text characters. Those characters do not have properties like a certain font or style.

You cannot "set the font on a BufferedWriter".
 
Justin Char
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you

I just wanted to know how if you could.

Or to find you can't do it.

You answered my question ...I appreciate it.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50277
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
Jinny Morris
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Campbell Ritchie! I've been trying to get my font list for a couple of days, and kept messing up my objects & methods - now I've got it! And learned some stuff in the process (mostly about what doesn't work, tho ...)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic