Skip to content
Snippets Groups Projects
Commit d784c90e authored by tcarver's avatar tcarver
Browse files

tidy

parent cca59534
No related branches found
No related tags found
No related merge requests found
...@@ -20,34 +20,35 @@ ...@@ -20,34 +20,35 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/MessageFrame.java,v 1.1 2004-06-09 09:47:08 tjc Exp $
**/ **/
package uk.ac.sanger.artemis.components; package uk.ac.sanger.artemis.components;
import uk.ac.sanger.artemis.Options; import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.*; import javax.swing.JButton;
import java.awt.event.*; import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.*;
/** /**
* A popup JFrame box that displays a message and has an OK JButton. * A popup JFrame box that displays a message and has an OK JButton.
*
* @author Kim Rutherford * @author Kim Rutherford
* @version $Id: MessageFrame.java,v 1.1 2004-06-09 09:47:08 tjc Exp $
**/ **/
public class MessageFrame extends JFrame { public class MessageFrame extends JFrame {
private static final long serialVersionUID = 1L;
/** /**
* Create a new MessageFrame component. * Create a new MessageFrame component.
* @param message The message to display in the JDialog and it's title. * @param message The message to display in the JDialog and it's title.
**/ **/
public MessageFrame (final String message) { public MessageFrame (final String message) {
this (message, message); this (message, message);
this.message = new JLabel (message);
} }
/** /**
...@@ -55,52 +56,32 @@ public class MessageFrame extends JFrame { ...@@ -55,52 +56,32 @@ public class MessageFrame extends JFrame {
* @param title The title of the new dialog JFrame. * @param title The title of the new dialog JFrame.
* @param message The message to display in the JDialog. * @param message The message to display in the JDialog.
**/ **/
public MessageFrame (final String title, protected MessageFrame (final String title,
final String message) { final String message) {
super (title); super (title);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.message = new JLabel (message);
getContentPane ().add (new JLabel (message), "North");
getContentPane ().add (this.message, "North"); final JButton ok_button = new JButton ("OK");
final JPanel panel = new JPanel ();
panel.add (ok_button);
ok_button.addActionListener (new ActionListener () { ok_button.addActionListener (new ActionListener () {
public void actionPerformed (ActionEvent e) { public void actionPerformed (ActionEvent e) {
MessageFrame.this.dispose (); MessageFrame.this.dispose ();
} }
}); });
addWindowListener (new WindowAdapter () {
public void windowClosing (WindowEvent event) {
MessageFrame.this.dispose ();
}
});
addKeyListener (new KeyAdapter () { addKeyListener (new KeyAdapter () {
public void keyTyped(final KeyEvent e) { public void keyTyped(final KeyEvent e) {
MessageFrame.this.dispose (); MessageFrame.this.dispose ();
} }
}); });
getContentPane ().add (panel, "South"); getContentPane ().add (ok_button, "South");
pack (); pack ();
final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
setLocation (new Point ((screen.width - getSize ().width) / 2, setLocation (new Point ((screen.width - getSize ().width) / 2,
(screen.height - getSize ().height) / 2)); (screen.height - getSize ().height) / 2));
setVisible (true); setVisible (true);
} }
final private JButton ok_button = new JButton ("OK");
/**
* This is the message displayed above the OK button. It can be set with
* setMessage ().
**/
private JLabel message;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment