Results 1 to 2 of 2

Thread: Brand New to Java - GUI issue

  1. #1

    Thread Starter
    Addicted Member Abrium's Avatar
    Join Date
    Feb 2007
    Location
    The Great State of Texas
    Posts
    205

    Brand New to Java - GUI issue

    Hello all I am brand new to Java and I am really trying to carry over what I have learned from .Net. I have done VB for two years now and now learning Java and I can't figure out why I can't get this GUI to pop up. Here is what I am working with thus far:

    Code:
    package langInterp;
    
    
    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    import javax.swing.JButton;
    import javax.swing.JLabel;
    
    
    
    
    
    
    //Start of the Class for the front end.
    @SuppressWarnings("serial")
    public class frontEnd extends JPanel{
    	
    
    frontEnd(){
    	BorderLayout border = new BorderLayout();
    	JFrame frame = new JFrame();
    	frame.setLayout(border);
    	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    	frame.setVisible(true);
    	frame.setSize(500,250);
    	frame.setLocation(450,450);
    	
    		JTextField textInput = new JTextField("", 25);
    	JButton btnGo = new JButton("Enter");
    	btnGo.addActionListener(new ActionListener() {
    		public void actionPerformed (ActionEvent e){
    			
    		}
    	});
    	
    		JLabel dispResult = new JLabel("");
    	frame.add(textInput, BorderLayout.NORTH);
    	frame.add(btnGo, BorderLayout.SOUTH);
    	frame.add(dispResult, BorderLayout.CENTER);
    	
    	
    }
    	
    
    
    	
    	
    	
    
    	public static void main(String[] args){
    javax.swing.SwingUtilities.invokeLater(new Runnable(){
    	public void run(){
    		new frontEnd();
    	}
    });
    	}
    }
    The frame pops up and is completely black. Any ideas?
    Abrium
    Asking the beginners questions so you don't have to!
    If by chance hell actually froze over and I some how helped you... Please rate.

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Brand New to Java - GUI issue

    setVisible should be the last method called
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

Posting Permissions

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



Click Here to Expand Forum to Full Width