Results 1 to 5 of 5
  1. #1
    AntaeusUK is offline Member
    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Unhappy Help, basic problem :(

    Hey all,

    I basically just need to create an empty window titled window1. What is wrong with my code?

    PS: I am not very good at java ^^.


    import java.awt.*;
    import javax.swing.*;
    /**
    * To create and display an empty window.
    *
    * @author 1
    * @version 1
    */
    public class Window1 extends JFrame {

    public static void window1() {
    /**
    * Constructor for objects of class Window1
    */

    JFrame frame = newJFrame("Empty Window");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
    frame.setPreferredSize(new Dimension(640, 480));

    frame.pack();
    frame.setVisible(true);

    }

    }
    Last edited by AntaeusUK; 11-06-2012 at 12:34 PM.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,440
    Blog Entries
    7
    Rep Power
    20

    Default Re: Help, basic problem :(

    A constructor does not have a return type and it has the same name as the class; so void window1() is not a constructor for the Window1 class.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    AntaeusUK is offline Member
    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Default Re: Help, basic problem :(

    Ok a quick update. It compiles now with out syntax errors since I put a space between new and JFrame. But now when I create an object (I'm using bluej) it says no accesible methods.

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,440
    Blog Entries
    7
    Rep Power
    20

    Default Re: Help, basic problem :(

    That class cannot be run as an application (it doesn't have a public static void main(String[] args) method).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    AntaeusUK is offline Member
    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Default Re: Help, basic problem :(

    Quote Originally Posted by JosAH View Post
    That class cannot be run as an application (it doesn't have a public static void main(String[] args) method).

    kind regards,

    Jos
    I fixed it thankyou for your help!!! Turned out I was missing some capital letters as well as the string args at the end! ^^ THanks again.

Similar Threads

  1. basic connect four problem
    By vicu1 in forum New To Java
    Replies: 0
    Last Post: 06-02-2012, 05:02 AM
  2. Basic Problem
    By odd123 in forum New To Java
    Replies: 6
    Last Post: 03-18-2012, 02:37 AM
  3. Very basic problem with a for loop.
    By Actaeonis in forum New To Java
    Replies: 5
    Last Post: 11-18-2011, 07:22 PM
  4. Very basic java problem
    By mrparker2 in forum New To Java
    Replies: 6
    Last Post: 05-26-2011, 08:50 PM
  5. What am I doing wrong in this basic problem
    By Blaedel in forum New To Java
    Replies: 10
    Last Post: 10-11-2009, 07:45 PM

Posting Permissions

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