Results 1 to 3 of 3
  1. #1
    kev670 is offline Member
    Join Date
    Oct 2010
    Posts
    20
    Rep Power
    0

    Default JFrames in netbeans

    I'm trying to build a JFrame application in netbeans but i cant seem to get the simple jframe code to compile on my computer. can someone tell me how to set up a project properly to get this code to compile please

    Java Code:
    import java.awt.*;	
    import javax.swing.*;	
    import java.awt.event.*;
    
    public class FrameDemo extends JFrame 
    { 
        public FrameDemo()	// Constructor 
        {
            super( "Frame Demo Application" );            
            Container c = getContentPane();
            c.setLayout(new FlowLayout
            Label prompt = new Label ("a Label component in a JFrame");
            c.add( prompt); 
            setSize(230, 100); 
            show();
        }
    
    public static void main( String args[] ) 
    {
        FrameDemo app = new FrameDemo();
    
        app.addWindowListener( 
    	new WindowAdapter() 
    	{
    		public void windowClosing( WindowEvent e ) 
    		{
    			System.exit( 0 );
                    }
    	});
    }
    }

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default

    c.setLayout(new FlowLayout --> c.setLayout(new FlowLayout());

    notes:
    dont mix awt and swing components !
    show is deprecated --> Component (Java Platform SE 6)

  3. #3
    kev670 is offline Member
    Join Date
    Oct 2010
    Posts
    20
    Rep Power
    0

    Default

    Thanks a lot dude. I got it running finally. There were also problems with the way i named things. Also changed show() to setVisible(true)... thanks again

Similar Threads

  1. help with jframes
    By pao09 in forum AWT / Swing
    Replies: 0
    Last Post: 04-15-2009, 02:10 PM
  2. jframes
    By ddj in forum AWT / Swing
    Replies: 0
    Last Post: 03-24-2009, 03:15 PM
  3. linking 2 Jframes
    By suhaib1thariq in forum New To Java
    Replies: 9
    Last Post: 02-13-2009, 01:30 AM
  4. problem with jframes
    By Robert in forum AWT / Swing
    Replies: 1
    Last Post: 01-16-2009, 03:05 AM
  5. two JFrames
    By kirtesh4u in forum New To Java
    Replies: 0
    Last Post: 11-17-2008, 08:26 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
  •