ESC key can now close the splash frame.

This commit is contained in:
Doublestrike
2011-09-01 04:07:48 +00:00
parent 28c64e19f9
commit c6290cd674

View File

@@ -6,12 +6,14 @@ import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
@@ -99,16 +101,7 @@ public class SplashFrame extends JFrame {
btnClose.setFocusPainted(false);
contentPane.add(btnClose);
btnClose.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent ae)
{
setSplashHasBeenClosed(true);
dispose();
}
});
// Action handler: button hover effect
btnClose.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent evt) {
btnClose.setBorder(BorderFactory.createLineBorder(Color.white));
@@ -121,7 +114,15 @@ public class SplashFrame extends JFrame {
}
});
// BG fills up with progress bar???
// Action handler: button close
btnClose.addActionListener(new closeAction());
// Action handler: esc key close
contentPane.getInputMap().put(
KeyStroke.getKeyStroke( "ESCAPE" ), "escAction" );
contentPane.getActionMap().put("escAction", new closeAction());
// Instantiate model and view and tie together.
monitorModel = new SplashProgressModel();
@@ -179,5 +180,18 @@ public class SplashFrame extends JFrame {
public final void setSplashHasBeenClosed(boolean neoState) {
SplashHasBeenClosed = neoState;
}
/**
* <p>closeAction</p>
* Closes the splash frame by toggling "has been closed" switch
* (to cancel preloading) and dispose() (to discard JFrame).
* @param SplashHasBeenClosed boolean.
*/
private class closeAction extends AbstractAction {
public void actionPerformed(ActionEvent e) {
setSplashHasBeenClosed(true);
dispose();
}
}
}