Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Help i cant get it to work any ideas thanks

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Help i cant get it to work any ideas thanks

    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.

    [code]
    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();


    }

    }
    }


  2. #2
    Junior Member
    Join Date
    Oct 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help i cant get it to work any ideas thanks

    Hint: Check out class scopes of variables.

Similar Threads

  1. Project ideas
    By seal308 in forum Collections and Generics
    Replies: 2
    Last Post: August 3rd, 2012, 02:27 PM
  2. NEED HELP WITH IDEAS
    By ash12 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 21st, 2012, 04:52 PM
  3. Any ideas?
    By ahender1 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 2nd, 2012, 03:58 PM
  4. Any Program Ideas?
    By Java Programmer in forum Java Theory & Questions
    Replies: 7
    Last Post: January 18th, 2012, 08:05 AM
  5. I need ideas on how to read this
    By thursgun in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: April 21st, 2010, 09:31 PM