Results 1 to 8 of 8
  1. #1
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Cool Why doesn't this create a window?

    Hi! I made this peice of code, almoste straight copy of the one in my java book.
    But when I run it, then it does nothing!
    It doesn't print an error while running nor when compiling, and it doesn't create a window!
    What is wrong?

    Heres my code:
    PHP Code:
    /**
     * @(#)Interface.java
     *
     *
     * @author 
     * @version 1.00 2009/9/16
     */
     
    import src.myapp;
    import javax.swing.*;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.*;
    
    public class run{
    	public static void main(String args[]){
    		try{
    			new GameFrame();
    		} catch (Exception e){
    			e.printStackTrace();
    		}
    	}
    }
    
    
    class GameFrame extends JFrame implements ActionListener {
    	JLabel status = new JLabel("");
    	JTextField textField = new JTextField(30);
    	JComboBox convertOpt = new JComboBox();
    	JButton go = new JButton("Start");
    	
        public GameFrame() throws IOException {
        	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        	setLayout(new FlowLayout());
        	add(status);
        	add(textField);
        	convertOpt.addItem("Crypt");
        	convertOpt.addItem("Decrypt");
        	add(convertOpt);
        	add(go);
        	go.addActionListener(this);
        	status.setText("Status: Inactive");
        	pack();
        	setVisible(true);
        }
        
        public void actionPerformed(ActionEvent e){
        	String path = textField.getText();
        	Boolean crypting  =false;
        	if (convertOpt.getSelectedItem().equals("Crypt")) {
        		crypting = true;
        	}
        	if (convertOpt.getSelectedItem().equals("Decrypt")){
        		crypting = false;
        	}
        	if (crypting != null){
        		try {
        			status.setText(crypting ? "Crypting" : "Decrypting");
        			myapp.Go(path,crypting);
        		} catch (Exception error){
        			error.printStackTrace();
        		}
        	} else {
        		status.setText("Choose a crypting Option!");
        	}
        }
        
        
    }
    Thanks for taking time reading :)

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

    Default

    Quote Originally Posted by Addez View Post
    Hi! I made this peice of code, almoste straight copy of the one in my java book.
    But when I run it, then it does nothing!
    It doesn't print an error while running nor when compiling, and it doesn't create a window!
    What is wrong?

    Heres my code:
    PHP Code:
    /**
     * @(#)Interface.java
     *
     *
     * @author 
     * @version 1.00 2009/9/16
     */
     
    import src.myapp;
    import javax.swing.*;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.*;
    
    public class run{
    Is the file called Interface.java?

  3. #3
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default

    no, so I removed that peice of comments..
    But still it doesnt do anything..

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    It creates a window for me. How did you try to run it?

  5. #5
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default

    Thats really weard...
    Hum...
    Ima see whats wrong..

  6. #6
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default

    aha! Jcreator messed it up and ran other file instead of this, tho the other file was in same project space so i never noticed xD

  7. #7
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    I'm sure Jcreator does what it's told to do.

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

    Default

    Quote Originally Posted by r035198x View Post
    I'm sure Jcreator does what it's told to do.
    Nah, it messed up; it does this all the time. Funny though, the more experienced the user becomes, the less the IDE does this.

Similar Threads

  1. 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
  2. how can i move one frame window to another window
    By santhosh_el in forum AWT / Swing
    Replies: 8
    Last Post: 06-10-2009, 03:36 PM
  3. Non Rectangular Window in SWT
    By Java Tip in forum SWT
    Replies: 0
    Last Post: 07-25-2008, 02:28 PM
  4. refresh a different window
    By marceldupont in forum AWT / Swing
    Replies: 3
    Last Post: 03-22-2008, 02:44 AM
  5. Replies: 0
    Last Post: 08-03-2007, 04:21 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
  •