Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
I'm just moving out of the text based part of the java course I'm trying to teach myself, and into the windowed part. The first few things I wrote and ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2003
    Location
    Cowpens, SC
    Posts
    96

    Font probs with Java


    I'm just moving out of the text based part of the java course I'm trying to teach myself, and into the windowed part. The first few things I wrote and compiled did fine, until I ran them. They run OK, but produce 20 or so occurrances of font errors in the konsole (adobe symbol seems to be the font it is looking for, altho Timesroman has been the specified font in the frames so far)

    After poking around for a while to see what fonts I have, I can find no Adobe fonts on the system (Strange, I have xpdf installed, as well as the utility that allows me to print to .pdf)

    I've looked on Sun's site, and Adobe's site for a font package that would solve this, and I have copied my Adobe fonts from the MS side of the box to floppy and tried to install them in KDE Contol panel. In all cases, "no fonts found"

    Any ideas?

  2. #2
    Just Joined!
    Join Date
    Aug 2003
    Location
    Cowpens, SC
    Posts
    96
    Here's the ouput from konsole, if it helps any:

    Font specified in font.properties not found [--symbol-medium-r-normal--*-%d-*-*-p-*-adobe-fontspecific]


    I get that 21 times, and it causes a brief hang

  3. #3
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682
    *moved to Programming section*

    What's the actual piece of code that is producing this error?
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

  4. #4
    Just Joined!
    Join Date
    Aug 2003
    Location
    Cowpens, SC
    Posts
    96
    Well, I'm not really sure. Right now, all I have done is a 'ComponentTestFrame' , a 'LabelTest' and a 'ButtonTest' that extend the ComponentTestFrame' (Well, a 'UselessFrame' also, that that was pretty well useless )

    Do you want me to post the sourcecode for them? I swear, the only font I specified was the 'Timesroman' mentioned above, so it must be a default call from the java package.

  5. #5
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682
    Yeah...post the code for the frame that uses the text that doesn't work.
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

  6. #6
    Just Joined!
    Join Date
    Aug 2003
    Location
    Cowpens, SC
    Posts
    96
    OK, It'll probably be after the first of the year. I've run out of netZero time already this month

    I don't have the info in front of me right now, and on a borrowed PC
    I appreciate the help, tho

  7. #7
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682
    Limited Internet Access? I would die.

    But when you get a chance, post the code and we'll work it out.
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

  8. #8
    Just Joined!
    Join Date
    Aug 2003
    Location
    Cowpens, SC
    Posts
    96
    OK, here's the code for the frame all the rest run in:
    Code:
    /*
    ComponentTestFrame
    *A simple frame to test components
    */
    
    import java.awt.*;
    import java.awt.event.*;
    
    public class ComponentTestFrame extends Frame implements WindowListener
    	{
    	public ComponentTestFrame(String title)
    		{
    		super(title);
    		setBackground(SystemColor.control);
    		setSize(400, 300);
    		setLocation(200, 150);
    		setLayout(new FlowLayout());
    		addWindowListener(this);
    		}
    	// The following is the only windowlistener that matters to this class
    	public void windowClosing(WindowEvent e)
    		{
    		dispose();
    		System.exit(0);
    		}
    	//The rest of them must still be declared
    	public void windowActivated(WindowEvent e) { }
    	public void windowClosed(WindowEvent e) { }
    	public void windowIconified(WindowEvent e) { }
    	public void windowDeiconified(WindowEvent e) { }
    	public void windowDeactivated(WindowEvent e) { }
    	public void windowOpened(WindowEvent e) { }
    	}
    And here is one of the .. problematic ones:
    Code:
    /*
    *LabelTest
    *Tests the Label component
    */
    
    import java.awt.*;
    
    public class LabelTest
    	{
    	public LabelTest()
    		{
    		//Make the labels
    		Label l1 = new Label("label");
    		Label l2 = new Label("I'm a label");
    		l2.setFont(new Font("Timeroman", Font.BOLD, 18));
    		Label l3 = new Label();
    		l3.setText("I am disabled");
    		l3.setEnabled(false);
    		Label l4 = new Label("Colored, Right aligned", Label.RIGHT);
    		l4.setForeground(Color.green);
    		l4.setBackground(Color.black);
    
    		//Make the frame and add the labels to it
    		ComponentTestFrame frame = new ComponentTestFrame("LabelTest");
    		frame.add(l1);
    		frame.add(l2);
    		frame.add(l3);
    		frame.add(l4);
    		frame.setVisible(true);
    		}
    	public static void main(String args[])
    		{
    		LabelTest lt = new LabelTest();
    		}
    	}
    I can't really see anything that would call any Adobe fonts.

    (BTW, I found some things called 'types' at adobes site, that I think are what I am missing. Man, are those guys proud of those things! )

  9. #9
    Linux Enthusiast scientica's Avatar
    Join Date
    Sep 2003
    Location
    South- or "Mid-" Sweden
    Posts
    742
    Quote Originally Posted by http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Font.html#Font(java.lang.String,%20int,%20int)
    Parameters:
    name - the font name. This can be a logical font name or a font face name. A logical name must be either: Dialog, DialogInput, Monospaced, Serif, or SansSerif. If name is null, the name of the new Font is set to the name "Default".
    style - the style constant for the Font The style argument is an integer bitmask that may be PLAIN, or a bitwise union of BOLD and/or ITALIC (for example, ITALIC or BOLD|ITALIC). If the style argument does not conform to one of the expected integer bitmasks then the style is set to PLAIN.
    thus you should probably use this:
    Code:
          l2.setFont(new Font("Serif", Font.BOLD, 18)); // Times is aserif font, I think this is the safest way to get a times looking font
    or
    Code:
          l2.setFont(new Font("Times New Roman", Font.BOLD, 18)); // don't know if there is a font by this name in linux thought

  10. #10
    Just Joined!
    Join Date
    Aug 2003
    Location
    Cowpens, SC
    Posts
    96
    OK, it accepted the Timesroman font argument, but returned errors for an Adobe symbol font. I tried replacing the lines in the source as suggested, and recompiled, with the same 20 occurances of an Adobe font specific error when running the resulting class

    It's not really a big deal, and it doesn't shut down the konsole or the class, but I do get a noticeable pause while it finds and reports these font errors. I only get this prob with Linux. not in my win98 environment(same java2 JDK installed on both, or at least from the same CD from the back of the book, {java2 JDK 1.3.1}).

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •