Results 1 to 3 of 3
  1. #1
    Zexanima is offline Member
    Join Date
    Sep 2011
    Posts
    4
    Rep Power
    0

    Question Having trouble with first GUI

    This is my first whack at making a program that has an actually GUI instead of runing in the console. I'm having a hard time though. I'm reading through the stuff on oracle but I can't seem to get this to work. I'm trying to get it to display a window with said background.(Image is in the directory.) How can I make this work?
    [Edit] Got in a hurry and forgot the code.]

    Java Code:
    import java.awt.*;
    import javax.swing.ImageIcon;
    import javax.swing.*;
    
    
    
    public class DisplayGUI {
    		
    	public DisplayGUI(){}
    	
    	public void showDisplay(){
    		
    
    		JFrame frame = new JFrame("blah blha asdfsadfd duurrrppp");
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    		JMenuBar greenMenuBar = new JMenuBar();
            greenMenuBar.setOpaque(true);
            greenMenuBar.setBackground(new Color(154, 165, 127));
            greenMenuBar.setPreferredSize(new Dimension(200, 20));
            
    
            ImageIcon label = createImageIcon("Zexanima.jpeg");
    
            
            frame.getContentPane().add(label, BorderLayout.CENTER);
            
            frame.setSize(400,500);
            frame.setVisible(true);
    	}
    
    
    
    }
    Last edited by Zexanima; 10-01-2011 at 11:01 AM.

  2. #2
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

    Default Re: Having trouble with first GUI

    Can you tell how you run it?
    Skype: petrarsentev
    http://TrackStudio.com

  3. #3
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,409
    Rep Power
    25

    Default Re: Having trouble with first GUI

    How can I make this work?
    you need to have a main() method in the class that you pass to the java command.

Similar Threads

  1. Io trouble need help
    By loopsnhoops in forum New To Java
    Replies: 18
    Last Post: 06-03-2011, 03:35 AM
  2. Having trouble with IO
    By loopsnhoops in forum New To Java
    Replies: 0
    Last Post: 06-02-2011, 04:06 AM
  3. GUI Trouble
    By rvgsd in forum New To Java
    Replies: 2
    Last Post: 03-07-2010, 12:10 AM
  4. Here comes trouble... :-)
    By sargehendricks in forum Introductions
    Replies: 1
    Last Post: 04-23-2009, 03:18 PM
  5. having some trouble
    By Unknown1369 in forum New To Java
    Replies: 13
    Last Post: 07-21-2008, 11:52 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
  •