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

    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");
    		JMenuBar greenMenuBar = new JMenuBar();
            greenMenuBar.setBackground(new Color(154, 165, 127));
            greenMenuBar.setPreferredSize(new Dimension(200, 20));
            ImageIcon label = createImageIcon("Zexanima.jpeg");
            frame.getContentPane().add(label, BorderLayout.CENTER);
    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
    Rep Power

    Default Re: Having trouble with first GUI

    Can you tell how you run it?
    Skype: petrarsentev

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    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