Results 1 to 7 of 7
  1. #1
    saba1998 is offline Member
    Join Date
    Nov 2012
    Posts
    4
    Rep Power
    0

    Question Simple GUI window

    HI
    NetBeans cannot run this program:
    Java Code:
    import java.awt.*;
    import javax.swing.*;
    
    // create a simple GUI window
    
    public class TopLevelWindow {
    
        private static void createWindow() {
            // cerate and set up the window
            JFrame frame = new JFrame("Simple GUI");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            
            JLabel textLabel = new JLabel("Testing Java Application",SwingConstants.CENTER);
            textLabel.setPreferredSize(new Dimension(300, 100));
            frame.getContentPane().add(textLabel, BorderLayout.CENTER);
            
            // Display the window
            frame.setLocationRelativeTo(null);
            frame.pack();
            frame.setVisible(true);
    
        }
        
        public static void main(String[] args) {
        
        
        }
        
    }
    when I press "run", it does nithing and please help me

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,960
    Rep Power
    8

    Default Re: Simple GUI window

    I've moved this thread to the Swing forum.

    You don't have anything in your main method. What do you expect to happen?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

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

    Default Re: Simple GUI window

    With this program I want to make a window like that: Simple GUI window-untitled.jpg

  4. #4
    saba1998 is offline Member
    Join Date
    Nov 2012
    Posts
    4
    Rep Power
    0

    Default Re: Simple GUI window

    Can u tell me what can i change in this code?

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Simple GUI window

    You need to call the method you've created in your main method. Sorry but this suggests that you've got the cart before the horse here. You need to learn basic Java before trying GUI stuff, at least the rudiments like creating and calling methods and such. I suggest that you start here: Trail: Learning the Java Language (The Java™ Tutorials)

  6. #6
    saba1998 is offline Member
    Join Date
    Nov 2012
    Posts
    4
    Rep Power
    0

    Default Re: Simple GUI window

    but can u tell me what can I add in this program.(I am a beginner in java and I cannot guess what are u talking about :) )

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,236
    Rep Power
    19

    Default Re: Simple GUI window

    Quote Originally Posted by saba1998 View Post
    but can u tell me what can I add in this program.(I am a beginner in java and I cannot guess what are u talking about :) )
    You're not expected to guess. Go through the tutorials linked by Fubarable and learn.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Closing secondary window from button in primary window
    By KoncentriK in forum New To Java
    Replies: 4
    Last Post: 02-26-2012, 01:24 AM
  2. Replies: 1
    Last Post: 07-25-2011, 10:24 AM
  3. Replies: 4
    Last Post: 01-10-2010, 07:48 AM
  4. change url in parent window from child window
    By rakesh_n_mehta in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 07-09-2009, 12:17 PM
  5. Replies: 6
    Last Post: 02-24-2009, 02:50 PM

Tags for this Thread

Posting Permissions

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