From c5390acbe0439fc18961a13a4ba7536ae62162f6 Mon Sep 17 00:00:00 2001 From: Brendan Date: Wed, 11 Mar 2015 16:32:45 -0600 Subject: [PATCH] adds ArmButton.java (forgot to commit it before) --- GroundStation/v2/ArmButton.java | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 GroundStation/v2/ArmButton.java diff --git a/GroundStation/v2/ArmButton.java b/GroundStation/v2/ArmButton.java new file mode 100644 index 0000000..d322b11 --- /dev/null +++ b/GroundStation/v2/ArmButton.java @@ -0,0 +1,25 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +class ArmButton extends JButton implements ActionListener { + private MessageContent content; + + public ArmButton( MessageContent newContent ) { + super( "Arm Flight Controller" ); + content = newContent; + setAlignmentX(Component.CENTER_ALIGNMENT); + addActionListener( this ); + } + + public void actionPerformed( ActionEvent evt ) { + if( getText().equals( "Arm Flight Controller" ) ) { + setText( "Disarm Flight Controller" ); + content.setMotorsEnabled( true ); + } + else { + setText( "Arm Flight Controller" ); + content.setMotorsEnabled( false ); + } + } +} \ No newline at end of file