Java Swing Question

Discussion in 'OT Technology' started by SPACECATAZ, Jan 26, 2010.

  1. SPACECATAZ

    SPACECATAZ New Member

    Joined:
    Dec 22, 2006
    Messages:
    2,502
    Likes Received:
    0
    I was given this assignment:

    [​IMG]



    I don't get why he's asking me to create a static JFrame variable named frame when he wants me to extend the JFrame class to begin with. I get all of its methods when I extend it...

    Also my code is printing out a big ass white box. :wtc:

    This is my code so far:

    Code:
    import java.awt.Frame;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    
    public class guiTresButtons extends JFrame implements ActionListener {
    	guiTresButtons(){
    		super("GUIThreeButtons");
    		JTextField width = new JTextField(10);
    		JTextField height = new JTextField(10);
    		JTextField area = new JTextField(10);
    
    
    		JFrame frame =  new JFrame();
    		
    		frame.setLayout(new GridLayout(3,3));
    
    		JLabel label_width = new JLabel("Width", SwingConstants.RIGHT);
    		frame.add(label_width);
    		frame.add(width);
    
    		frame.setSize(300, 400);
    		frame.setVisible(true);
    	}
    
    
    
    
    	@Override
    	public void actionPerformed(ActionEvent aex) {
    		JTextField width = new JTextField();
    
    	}
    
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args) {
    		JFrame frame = new guiTresButtons();
    		
    
    	}
    
     
  2. ge0

    ge0 New Member

    Joined:
    Oct 31, 2005
    Messages:
    8,398
    Likes Received:
    0
    Location:
    JERSEY
    sub class
     

Share This Page