Results 1 to 2 of 2
  1. #1
    dbashby's Avatar
    dbashby is offline Senior Member
    Join Date
    Mar 2009
    Posts
    223
    Rep Power
    6

    Question Disabling a button at EOF

    My application writes data to a text file, I have buttons such as the next button that is disabled until the first button is clicked, then you can hit the next button to go through all the data stored on file.

    However my problem is that I am trying to get it so the next button is disabled on the last record so that rather than the eof message be displayed you know from when the button is greyed out that you are at the end of file.

    I would be grateful for any help, I have only been studying java for a few months, this seems to be an impossible task at the moment.

    Thanks in advance.:confused:

  2. #2
    dbashby's Avatar
    dbashby is offline Senior Member
    Join Date
    Mar 2009
    Posts
    223
    Rep Power
    6

    Question Disable button at EOF

    My file has three records, I have managed to disable the next button but unfortunately it disables after showing the 2nd record not 3rd(last)

    I also think I have it in the wrong place, although the app works I think that it should go directly under the catch EOF.

    Has anyone got a suggestion of how to solve this or am I going in the right direction?

    try {
    //file is already open
    record = (videoRecord)input.readObject(); //read whole record
    // put record fields in to the screen fields
    txtClassification.setText(record.getClassification ());
    txtTitle.setText(record.getTitle());
    txtDuration.setText(Integer.toString(record.getDur ation()));
    txtHireCost.setText(Float.toString(record.getHireC ost()));
    }
    catch (IOException e) {
    optPane1.showMessageDialog(this, "IO Error reading file, possible EOF","File Read Error",optPane1.ERROR_MESSAGE);


    }
    catch (ClassNotFoundException e) {
    optPane1.showMessageDialog(this, "Class Error reading next record","File Read Error",optPane1.ERROR_MESSAGE);
    /* the script below should disable the next button on display of the last record */
    ok = false;}
    cmdNext.setEnabled(false);



    }

Similar Threads

  1. Disabling part of a method
    By juru in forum Advanced Java
    Replies: 10
    Last Post: 10-27-2008, 02:41 AM
  2. Replies: 0
    Last Post: 07-07-2008, 05:35 PM
  3. [SOLVED] Disabling a button not working
    By Leprechaun in forum New To Java
    Replies: 2
    Last Post: 04-24-2008, 05:46 AM
  4. Using SWT Button
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-08-2008, 10:05 AM
  5. disabling JButtons after win in TicTacToe
    By noisepoet in forum New To Java
    Replies: 1
    Last Post: 05-19-2007, 12:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •