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 5 of 5

Thread: (Beginner) Need some help with display

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default (Beginner) Need some help with display

    Hello I am new to the forum so first I would like to say hello!

    I am a beginner and just started learning to use Java 2 days ago. I am having an issue with getting a display box to show up. I am working from a tutorial at the moment and I am using the Eclipse IDE however when I try to compile and run I receive an error that states

    Severity and DescriptionPath Resource Location Creation Time Id
    The serializable class Board does not declare a static final serialVersionUID field of type long Uadventure/src/uadventure Board.java line 5 1352751766061 40

    Here is the code I am working with:

    package uadventure;

    import javax.swing.JFrame;

    public class Board extends JFrame {

    public Board() {
    add(new Board());
    setTitle("Display");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(1280, 800);
    setLocationRelativeTo(null);
    setVisible(true);
    setResizable(false);
    }

    public static void main(String[] args) {
    new Board();
    }
    }

    Getting a box to display just isn't working. Like I said I am working from a tutorial and I even tried using the tutorial code as well and the same problem arises. I have been doing alot of reading and understand how things work but I seem to struggle getting the basics of a project going once I can get the display working I can then move onto getting things together. Any help with this problem would be greatly appreciated.

    Thanks
    Justin


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,297
    Thanks
    180
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: (Beginner) Need some help with display

    Are you getting a compile time error, or a compile time warning? The message you posted is a warning, and the code should have compiled and class file generated based upon the code you posted (the warning has to do with Serialization - see Serializable Objects (The Java™ Tutorials > Java Naming and Directory Interface > Java Objects in the Directory) )

  3. #3
    Junior Member
    Join Date
    Nov 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: (Beginner) Need some help with display

    It is showing as a warning. After I compile and run it the console gives me these errors.

    Exception in thread "main" java.lang.StackOverflowError
    at java.util.HashMap.getEntry(Unknown Source)
    at java.util.HashMap.get(Unknown Source)
    at sun.awt.AppContext.get(Unknown Source)
    at com.sun.java.swing.SwingUtilities3.getDelegateRepa intManager(Unknown Source)
    at javax.swing.RepaintManager.getDelegate(Unknown Source)
    at javax.swing.RepaintManager.addDirtyRegion(Unknown Source)
    at javax.swing.JComponent.repaint(Unknown Source)
    at java.awt.Component.repaint(Unknown Source)
    at javax.swing.JComponent.setBackground(Unknown Source)
    at javax.swing.LookAndFeel.installColors(Unknown Source)
    at javax.swing.LookAndFeel.installColorsAndFont(Unkno wn Source)
    at javax.swing.plaf.basic.BasicPanelUI.installDefault s(Unknown Source)
    at javax.swing.plaf.basic.BasicPanelUI.installUI(Unkn own Source)
    at javax.swing.JComponent.setUI(Unknown Source)
    at javax.swing.JPanel.setUI(Unknown Source)
    at javax.swing.JPanel.updateUI(Unknown Source)
    at javax.swing.JPanel.<init>(Unknown Source)
    at javax.swing.JPanel.<init>(Unknown Source)
    at javax.swing.JPanel.<init>(Unknown Source)
    at javax.swing.JRootPane.createGlassPane(Unknown Source)
    at javax.swing.JRootPane.<init>(Unknown Source)
    at javax.swing.JFrame.createRootPane(Unknown Source)
    at javax.swing.JFrame.frameInit(Unknown Source)
    at javax.swing.JFrame.<init>(Unknown Source)
    at uadventure.Board.<init>(Board.java:7)
    at uadventure.Board.<init>(Board.java:8)
    at uadventure.Board.<init>(Board.java:8)
    at uadventure.Board.<init>(Board.java:8)

    And uadventure.board repeats many times

    Here is an image of eclipse

    error.jpg

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,297
    Thanks
    180
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: (Beginner) Need some help with display

    Think about how the program proceeds. The main method is entered, and you create a Board. Doing so calls the Board class constructor. When the constructor is called, it attempts to add a Board, which in turn calls the Constructor, and so on ad infinitum. In other words, the code repetitively calls itself. Don't try to add a class to itself in this manner.

  5. The Following User Says Thank You to copeg For This Useful Post:

    JustinR (November 13th, 2012)

  6. #5
    Junior Member
    Join Date
    Nov 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: (Beginner) Need some help with display

    Ah I see thank you very much I got it working and I can see how it was repeating itself.

Similar Threads

  1. Can't display an image...
    By barebackingtiger in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 25th, 2012, 06:21 PM
  2. GridBagLayout display problem
    By mjpam in forum What's Wrong With My Code?
    Replies: 0
    Last Post: May 5th, 2011, 04:58 PM
  3. Display in JOptionPane
    By t-rank in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 19th, 2010, 12:09 AM
  4. Display file name
    By Puk284 in forum Java Servlet
    Replies: 1
    Last Post: April 13th, 2010, 03:13 AM
  5. display time
    By kalees in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: January 1st, 2010, 06:40 AM