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: how to stall a gui program

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    6
    My Mood
    Nerdy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to stall a gui program

    hi guys,

    i am working on a program which allows a user to type in details about desktops and laptops,
    details such as, name, ram size, hdd size and screen size. there is a text field for each of these details, the information is the sent to an xml file.

    the second part of the program allows the user to display this info on a table.

    my question is, is it possible to stall a program if the user leaves a JTextfield blank.

    when a field is left blank the element in the xml file looks like this:
    <name/>

    i tried to make a try/catch statement to stop the program

    String itemName = name.getText();
     
    try{
          itemName.equals("");
    }catch(Exception e){
       system.out.print("error");
    }

    i tried this which dose print an "error" on the console in eclipse but the info still gets printed into an xml file, what i want to do is stop the program from sending the info to the xml file until the text fields are filled.

    thanks in advanced.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: how to stall a gui program

    is it possible to stall a program if the user leaves a JTextfield blank.
    Not sure what "stall" means. If you disable all buttons etc until the user has entered all needed data, the user will not be able to press any buttons until they are enabled.
    Use listeners for all the input fields you want to ensure are filled and have them indicate that the data is present by using a flag.

    i want to do is stop the program from sending the info to the xml file until the text fields are filled
    This can be done by testing all the fields just before outputting the file. If any are not complete, send a message to the user and exit/return to wait for the user to enter the data.

Similar Threads

  1. Help with class program!!! STUCK! Program not doing what I Want!!!
    By sketch_flygirl in forum What's Wrong With My Code?
    Replies: 7
    Last Post: April 4th, 2011, 07:29 AM