public void actionPerformed(ActionEvent e) { // Handle open button action. if (e.getSource() == openButton) { int returnVal = fc.showOpenDialog(DirectorySize.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); // This is where a real application would open the file. ListSubDirectorySizes(file); } else { log.append("Open command cancelled by user." + newline); } log.setCaretPosition(log.getDocument().getLength()); // Handle save button action. } else if (e.getSource() == saveButton) { log.setText(""); // reset } }
public void displayMessage(String message, boolean error) { if (error) messageLbl.setForeground(Color.red); else messageLbl.setForeground(UIManager.getColor("Label.foreground")); messageLbl.setText(message); }