mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
ESC key can now close the splash frame.
This commit is contained in:
@@ -6,12 +6,14 @@ import java.awt.Font;
|
|||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.KeyStroke;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
@@ -99,16 +101,7 @@ public class SplashFrame extends JFrame {
|
|||||||
btnClose.setFocusPainted(false);
|
btnClose.setFocusPainted(false);
|
||||||
contentPane.add(btnClose);
|
contentPane.add(btnClose);
|
||||||
|
|
||||||
btnClose.addActionListener(new ActionListener()
|
// Action handler: button hover effect
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent ae)
|
|
||||||
{
|
|
||||||
setSplashHasBeenClosed(true);
|
|
||||||
dispose();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
btnClose.addMouseListener(new java.awt.event.MouseAdapter() {
|
btnClose.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||||
public void mouseEntered(java.awt.event.MouseEvent evt) {
|
public void mouseEntered(java.awt.event.MouseEvent evt) {
|
||||||
btnClose.setBorder(BorderFactory.createLineBorder(Color.white));
|
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.
|
// Instantiate model and view and tie together.
|
||||||
monitorModel = new SplashProgressModel();
|
monitorModel = new SplashProgressModel();
|
||||||
@@ -179,5 +180,18 @@ public class SplashFrame extends JFrame {
|
|||||||
public final void setSplashHasBeenClosed(boolean neoState) {
|
public final void setSplashHasBeenClosed(boolean neoState) {
|
||||||
SplashHasBeenClosed = 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user