Java Reference
In-Depth Information
openButton.addActionListener(this);
nextButton = new JButton("Next Record");
nextButton.addActionListener(this);
nextButton.setEnabled(false);
//(No fi le open yet.)
buttonPanel.add(openButton);
buttonPanel.add(nextButton);
add(buttonPanel, BorderLayout.SOUTH);
addWindowListener(
new WindowAdapter()
{
public void windowClosing(
WindowEvent event)
{
if (input != null) //A fi le is open.
input.close();
System.exit(0);
}
}
);
}
public void actionPerformed(ActionEvent event)
{
if (event.getSource() == openButton)
{
try
{
openFile();
}
catch(IOException ioEx)
{
JOptionPane.showMessageDialog(this,
"Unable to open fi le!");
}
}
else
{
try
{
readRecord();
}
catch(EOFException eofEx)
{
nextButton.setEnabled(false);
Search WWH ::




Custom Search