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.


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

Results 1 to 2 of 2

Thread: problems with event handlers

  1. #1
    Join Date
    Mar 2013
    Thanked 0 Times in 0 Posts

    Default problems with event handlers

    I have a GUI project, but the instructions I'm given on what is supposed to happen in each event handler is uncleared.
    For one of them, it is supposed to delete a file made in another event handler. However, I do not know how to delete the file. Can someone help me with this?
    For a different event handler, it is supposed to check to make sure all fields are filled in, but I do not know how to write the code to check this. I'm also supposed to store 4 pieces of data to a file on a separate line. However, i don't know how to do this. I have another method, but I don't think I can put a method into a event handler. Can someone help me with this too?

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Eastern Florida
    Thanked 2,460 Times in 2,411 Posts

    Default Re: problems with event handlers

    how to delete the file
    See the File class. It has a method to delete a file.

    make sure all fields are filled in,
    If they are textfields, get the text that they hold and check for valid contents. The String class has methods to check if there is any data in the String that you get from the text fields.

    store 4 pieces of data to a file on a separate line
    Look at the PrintWriter class for an easy way to write lines with data to a file.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Need help with button handlers
    By iggyggy in forum AWT / Java Swing
    Replies: 5
    Last Post: November 18th, 2012, 10:46 AM
  2. Handlers and Classes/Interfaces
    By lightOfDay in forum Object Oriented Programming
    Replies: 0
    Last Post: August 26th, 2012, 02:41 AM
  3. Event Handling
    By maress in forum What's Wrong With My Code?
    Replies: 0
    Last Post: January 24th, 2011, 03:29 AM
  4. Multiple Identical Scripts - Variables and Load Handlers
    By cas22 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 22nd, 2011, 11:37 AM