File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes another .ttf question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "another .ttf question" Watch "another .ttf question" New topic
Author

another .ttf question

Chris Dancy
Ranch Hand

Joined: Feb 14, 2006
Posts: 136
hey guys i got another question on using the .ttf files. I want to leave the commented sections out. What i was trying to do was to set the fonts individually on the components but when i tried, it typed in teeny weeny size letters, and wasent even readable. Can anyone help me out. i just want to leave the code the way it is, but just be able to set the desired components to the imported font.

public Converter()
{
try{
InputStream in = Converter.class.getResourceAsStream("Augustin.ttf");
Font font = Font.createFont(Font.TRUETYPE_FONT,in);


c = new Conversions();
super.setLayout(new GridLayout(3,1));

label1 = new JLabel("Enter Fahrenheit:");
field1 = new JTextField(5);
field1.addActionListener(new FahrenheitListener());
button1 = new JButton("CONVERT");
button1.addActionListener(new FahrenheitListener());
label2 = new JLabel("to Celsius:");
field2 = new JTextField(8);
field2.setEditable(false);
panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
panel1.add(label1);
panel1.add(field1);
panel1.add(button1);
panel1.add(label2);
panel1.add(field2);
add(panel1);

label3 = new JLabel("Enter Celsius:");
field3 = new JTextField(5);
field3.addActionListener(new CelsiusListener());
button2 = new JButton("CONVERT");
button2.addActionListener(new CelsiusListener());
label4 = new JLabel("to Fahrenheit:");
field4 = new JTextField(8);
field4.setEditable(false);
panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
panel2.add(label3);
panel2.add(field3);
panel2.add(button2);
panel2.add(label4);
panel2.add(field4);
add(panel2);

button3 = new JButton("CLEAR");
button3.addActionListener(new button3Listener());

button4 = new JButton("CHANGE BACKGROUND COLOR");
button4.addActionListener(new button4Listener());

button5 = new JButton("EXIT");
button5.addActionListener(new button5Listener());

panel3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
panel3.add(button4);
panel3.add(button3);
panel3.add(button5);
add(panel3);
}catch(Exception ex){ex.printStackTrace();}


("Anger is not an emotion, its a symptom of fear.")
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
I don't understand what you're asking -- what do you mean by "I want to leave the commented sections out"? Anyway, you mentioned teeny fonts. I think that's because the following line:

Font font = Font.createFont(Font.TRUETYPE_FONT,in);

creates a font of size 1!!! Luckily, it's easy to derive a font with a different size:

Font font12 = font.deriveFont((float)12);

Be careful -- methods deriveFont(int) and deriveFont(float) are very different!


There is no emoticon for what I am feeling!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: another .ttf question