RasPi/GroundStation/v2/EStopWindow.java

96 lines
2.3 KiB
Java
Raw Normal View History

2015-02-26 14:09:39 -07:00
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
/**
*
*/
class EStopWindow extends JFrame implements ActionListener {
/** list to hold subscribed actionlisteners */
private ArrayList<ActionListener> listeners = new ArrayList<ActionListener>();
/** stop sign image */
//private Image sign = new Image( "./stopSign.png" );
/** Emergency stop button */
private JButton disableButton;
/**
*
*/
2015-03-02 14:45:13 -07:00
public EStopWindow( boolean visible) {
2015-02-26 14:09:39 -07:00
super("Emergency Stop");
setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE );
setAlwaysOnTop( true );
setLocation( 600, 100 );
//disableButton = new JButton( "DISABLE" );
disableButton = new JButton( new ImageIcon( (new ImageIcon( "./stopSign.png" )).getImage().getScaledInstance( 200, 200, Image.SCALE_DEFAULT) ) );
disableButton.addActionListener( this );
add( disableButton );
setEnabled( true );
pack();
2015-03-02 14:45:13 -07:00
setVisible( visible );
}
/**
*
*/
public EStopWindow() {
this( true );
2015-02-26 14:09:39 -07:00
}
/**
*
*/
public void actionPerformed( ActionEvent evt ) {
if( evt.getSource() == disableButton ) {
fireActionPerformed();
}
}
/////////////////////////////////////
/**
*
*/
public void setEnabled( boolean enable ) {
disableButton.setEnabled( enable );
}
/**
* adds actionlistener to subscribd listener list
* @param al - actionlistener to add
*/
public void addActionListener( ActionListener al ) {
listeners.add( al );
}
/**
* removes actionlistener from subscribed listener list
* @param al - actionlistener to remove
*/
public void removeActionListener( ActionListener al ) {
listeners.remove( al );
}
/**
* sends an actionevent to subscribed listeners
* @param ae - actionevent to use as parameter to all subscribed listeners
*/
public void fireActionPerformed( ActionEvent ae ) {
for( ActionListener al : listeners ) {
al.actionPerformed( ae );
}
}
/**
*
*/
public void fireActionPerformed() {
fireActionPerformed( new ActionEvent( this, ActionEvent.ACTION_PERFORMED, "CLICKED" ) );
}
}