Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Eclipse Kepler + Parabola Gnu/linux errors at runtime(font-related?)

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Eclipse Kepler + Parabola Gnu/linux errors at runtime(font-related?)

    Hello,

    I am running Parabola Gnu/linux with the 3.10 lts kernel (later kernels still have problems with the graphical part, so...)
    I'm beginning to learn java and have some really easy code, that gives me a long list of errors at runtime. Also a fair bit of warnings in the code itself, but always the same: " The serializable class Oef0310 does not declare a static final serialVerionUID field of type long"
    I've had this problmen since I've started doing these exercices, they don't give any problem.

    When running code on Ubuntu & Eclipse Indigo, I get no error at all. I checked the Arch wiki page and found this: https://wiki.archlinux.org/index.php...font_rendering

    But I don't understand what they mean by options. So here's my code:

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
     
     
     
    public class Oef0310 extends JFrame {
    	public static void main(String args[]) {
    		JFrame frame = new Oef0310();
    		frame.setSize(600, 300);
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.setTitle("Oef 3.10");
     
    		frame.setContentPane(new Optelpaneel0310());
    		frame.setVisible(true);
     
     
    	}
    }
     
     
     
    // second class
     
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
     
    public class Optelpaneel0310 extends JPanel {
    	private JTextField invoervak1, invoervak2, optelVak, maalVak;
    	private JButton plusKnop, maalKnop;
     
     
    	public Optelpaneel0310() {
    		invoervak1 = new JTextField(10);
    		invoervak2 = new JTextField(10);
    		optelVak = new JTextField(10);
    		maalVak = new JTextField(10);
     
    		plusKnop = new JButton(" + ");
    		plusKnop.addActionListener(new PlusKnopHandler() );
     
    		maalKnop = new JButton(" * ");
    		maalKnop.addActionListener(new MaalKnopHandler() );
     
    		add(invoervak1);
    		add(invoervak2);
    		add(plusKnop);
    		add(maalKnop);
    		add(optelVak);
    		add(maalVak);
     
    	}
     
     
    	class PlusKnopHandler implements ActionListener {
    		public void actionPerformed(ActionEvent e) {
    			String invoerstring1 = invoervak1.getText();
    			int getal1 = Integer.parseInt(invoerstring1);
     
    			String invoerstring2 = invoervak2.getText();
    			int getal2 = Integer.parseInt(invoerstring2);
     
    			int resultaat = getal1 + getal2;
     
    			optelVak.setText("" + resultaat ); 
    		}
    	}
     
    	class MaalKnopHandler implements ActionListener {
    	 	public void actionPerformed(ActionEvent e) {
    			String invoerstring1 = invoervak1.getText();
    			int getal1 = Integer.parseInt(invoerstring1);
     
    			String invoerstring2 = invoervak2.getText();
    			int getal2 = Integer.parseInt(invoerstring2);
     
    			int resultaat = getal1 * getal2;
     
    			maalVak.setText("" + resultaat);
    		}
    	}
     
    }

    And here are the errors
    Exception in thread "main" java.lang.NullPointerException
    at sun.awt.X11FontManager.getDefaultPlatformFont(X11F ontManager.java:779)
    at sun.font.SunFontManager$2.run(SunFontManager.java: 432)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.font.SunFontManager.<init>(SunFontManager.java :375)
    at sun.awt.X11FontManager.<init>(X11FontManager.java: 32)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Construc tor.java:526)
    at java.lang.Class.newInstance(Class.java:374)
    at sun.font.FontManagerFactory$1.run(FontManagerFacto ry.java:83)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.font.FontManagerFactory.getInstance(FontManage rFactory.java:74)
    at sun.font.SunFontManager.getInstance(SunFontManager .java:249)
    at sun.font.FontDesignMetrics.getMetrics(FontDesignMe trics.java:264)
    at sun.swing.SwingUtilities2.getFontMetrics(SwingUtil ities2.java:1003)
    at javax.swing.JComponent.getFontMetrics(JComponent.j ava:1615)
    at javax.swing.text.PlainView.calculateLongestLine(Pl ainView.java:639)
    at javax.swing.text.PlainView.updateMetrics(PlainView .java:209)
    at javax.swing.text.PlainView.setSize(PlainView.java: 490)
    at javax.swing.plaf.basic.BasicTextUI$RootView.setSiz e(BasicTextUI.java:1714)
    at javax.swing.plaf.basic.BasicTextUI.getPreferredSiz e(BasicTextUI.java:917)
    at javax.swing.JComponent.getPreferredSize(JComponent .java:1651)
    at javax.swing.JTextField.getPreferredSize(JTextField .java:424)
    at java.awt.FlowLayout.layoutContainer(FlowLayout.jav a:609)
    at java.awt.Container.layout(Container.java:1503)
    at java.awt.Container.doLayout(Container.java:1492)
    at java.awt.Container.validateTree(Container.java:168 8)
    at java.awt.Container.validateTree(Container.java:169 7)
    at java.awt.Container.validateTree(Container.java:169 7)
    at java.awt.Container.validateTree(Container.java:169 7)
    at java.awt.Container.validate(Container.java:1623)
    at java.awt.Container.validateUnconditionally(Contain er.java:1660)
    at java.awt.Window.show(Window.java:1033)
    at java.awt.Component.show(Component.java:1651)
    at java.awt.Component.setVisible(Component.java:1603)
    at java.awt.Window.setVisible(Window.java:1014)
    at Oef0310.main(Oef0310.java:15)


    Also, I had other code compile and run without a problem on that machine, eg
    import javax.swing.*;
    import java.awt.*;

    public class Tekenpaneel0306 extends JPanel {
    	public Tekenpaneel0306() {
    		setBackground(Color.WHITE);
    	}
     
    	public void paintComponent(Graphics g) {
    		g.setColor(Color.BLACK);
     
    		g.fillRect(0, 0, 50, 50);
    		g.fillRect(100, 100, 50, 50);
    		g.fillRect(100, 0, 50, 50);
    		g.fillRect(50, 50, 50, 50);
    		g.fillRect(0, 100, 50, 50);
     
    		g.setColor(Color.WHITE);
     
    		g.fillRect(50, 0, 50, 50);
    		g.fillRect(0, 50, 50, 50);
    		g.fillRect(100, 50, 50, 50);
    		g.fillRect(50, 100, 50, 50);
    	}
    }


    What couldpossibly be wrong ? Someone told me something about fonts, but... Buh.

    I appreciate any help.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Eclipse Kepler + Parabola Gnu/linux errors at runtime(font-related?)

    The warning, " The serializable class Oef0310 does not declare a static final serialVerionUID field of type long" is simply that, a warning that you can ignore and even suppress for now.
    I've had this problmen since I've started doing these exercices, they don't give any problem.
    The above statement is confusing. I can't tell if you're having a problem or when you're having a problem. Can you be more specific about what code is giving you problems (if any) and the conditions under which the code causes problems?

    When I run your code and enter numbers in the first 2 text fields and press either the '+' or '*' buttons, I get a result in either the third or fourth text field with no errors.

    I have never seen the kind of font errors you're getting. Since there are times when you are not getting errors (apparently), then it will be necessary to determine what's different about the code or the conditions under which that code is being run when you are seeing errors, and you haven't made that clear.

  3. #3
    Junior Member
    Join Date
    Mar 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Eclipse Kepler + Parabola Gnu/linux errors at runtime(font-related?)

    I meant I didnt have problems, until 3.10. The class Tekenpaneel is part of exercice 3.6, and that runs without a problem (that's what I meant, but my sentence was wrong, sorry)

    So, the class Optelpaneel0310 gives me the long list of errors you see. The class Tekenpaneel0306 doesn't.
    The class Oef0310 is always kind of the same, very similar to Oef0306.
    If, in that class, I remove frame.setVisible(true); I don't get an errors, but ofcourse I don't have *anything*

    Strange thing is I get no errors on Ubuntu, I know there is nothing wrong at all with my code.

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Eclipse Kepler + Parabola Gnu/linux errors at runtime(font-related?)

    This sounds more like either an OS or Java development environment installation/setup question, but I'm not sure which, and I don't think you mentioned the OS/environment where you are getting the error(s). I agree that your code is error free, though it may not be the best it can be.

    Your use of a test class that extends JFrame with a main() method to create an instance of that class just to get a JFrame instance is odd. Why not just create a JFrame object:

    JFrame frame = new JFrame();

    And then the Swing app should be run on the EDT rather than on the main thread as you're currently doing.

    But you didn't ask about any of that.

Similar Threads

  1. Re: How to Change JTextArea font, font size and color
    By binokyo10 in forum Java Theory & Questions
    Replies: 1
    Last Post: February 5th, 2012, 12:12 PM
  2. How to Change JTextArea font, font size and color
    By Flash in forum Java Swing Tutorials
    Replies: 7
    Last Post: January 14th, 2012, 10:47 PM
  3. [SOLVED] Eclipse in Linux?
    By beer-in-box in forum Java IDEs
    Replies: 2
    Last Post: September 27th, 2011, 07:39 AM
  4. In eclipse how do you get the runtime of your program?
    By beginnerprogrammer in forum Java Theory & Questions
    Replies: 5
    Last Post: May 22nd, 2011, 03:19 PM
  5. miniBuilder on Linux- java errors
    By nwtjv in forum Exceptions
    Replies: 0
    Last Post: March 25th, 2010, 06:54 AM