2 Replies - 261 Views - Last Post: 30 October 2012 - 07:28 AM Rate Topic: -----

#1 freshtilldeath0  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 29-October 12

Can somebody help me cant get it to work thanks

Posted 30 October 2012 - 05:02 AM

Hi i am having a problem getting this to work i want to add the user input input from the text field "Line 13" so i can add it to "newFile = new File("C:/Users/Administrator.Dan-HP/Desktop/" + input + ".txt");" but where i put input it doesn't work becuase it cant recognize input, if i remove input and just put hello.txt in "" thwn it runs but i need it be renamed by the user. any ideas? also they are both in two different class files ion the same package.

	public class window extends JFrame{
	 
	public static JTextField textField;
	 
	public window(){
	 
	textField = new JTextField(20);
	add(textField);
	 
	textField.addActionListener(new ActionListener(){
	public void actionPerformed(ActionEvent e){

	String input = textField.getText();
	 
	} 
	});
	 
	}
	 
	}
	 
	 
	 
	public class fileCreation{ 
	 
	public static void files ()throws IOException{ 
	 
	 
	 
	File newFile;
	newFile = new File("C:/Users/Administrator.Dan-HP/Desktop/" + input + ".txt");
	 
	if(!newFile.exists()){
	 
	newFile.createNewFile();
	 
	 
	}
	 
	}
	 	}




Is This A Good Question/Topic? 0
  • +

Replies To: Can somebody help me cant get it to work thanks

#2 darek9576  Icon User is offline

  • D.I.C Lover

Reputation: 198
  • View blog
  • Posts: 1,693
  • Joined: 13-March 10

Re: Can somebody help me cant get it to work thanks

Posted 30 October 2012 - 05:10 AM

Can somebody help me cant get it to work thanks



is not very descriptive.
Was This Post Helpful? 0
  • +
  • -

#3 Dirnol  Icon User is offline

  • New D.I.C Head

Reputation: 15
  • View blog
  • Posts: 31
  • Joined: 15-October 12

Re: Can somebody help me cant get it to work thanks

Posted 30 October 2012 - 07:28 AM

Where is your main method? Please post all of your code, right now it looks like you've created two classes that are completely unrelated and do not interact at all, and you want them to work together.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1