Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    some of JFrame's methods aren't working, might have imported wrong?

    This site, http://docs.oracle.com/javase/tutori...nts/frame.html, has this sample code

    Code:
    //1. Create the frame.
    JFrame frame = new JFrame("FrameDemo");
    
    //2. Optional: What happens when the frame closes?
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    //3. Create components and put them in the frame.
    //...create emptyLabel...
    frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
    
    //4. Size the frame.
    frame.pack();
    
    //5. Show it.
    frame.setVisible(true);
    I tried to use it in an eclipse project of my own (purely for fun, not homework), and two of the methods, SetDefaultClose and getContentPanel are expecting identifiers. By the way, I haven't programmed in Java in ages and am trying to get back into it by building a very simple game.


  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    You have no main method, add your main and put all that in it.
    The import is incorrect, you aren't using a awt package here, but there is no call to Frame anyway, and JFrame will be included with the swing.*.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  

    Posting Permissions

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