Results 1 to 2 of 2
Thread: Disabling a button at EOF
- 03-09-2009, 11:15 PM #1
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:
- 03-10-2009, 03:37 PM #2
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
-
Disabling part of a method
By juru in forum Advanced JavaReplies: 10Last Post: 10-27-2008, 02:41 AM -
Enabling/disabling menu depending on clipboard content availability
By Java Tip in forum SWT TipsReplies: 0Last Post: 07-07-2008, 05:35 PM -
[SOLVED] Disabling a button not working
By Leprechaun in forum New To JavaReplies: 2Last Post: 04-24-2008, 05:46 AM -
Using SWT Button
By Java Tip in forum Java TipReplies: 0Last Post: 01-08-2008, 10:05 AM -
disabling JButtons after win in TicTacToe
By noisepoet in forum New To JavaReplies: 1Last Post: 05-19-2007, 12:01 AM
Bookmarks