javaInterface: OswaldInterfaceTest.java

File OswaldInterfaceTest.java, 1.0 kB (added by goskab, 6 months ago)

Oswald "emulation" gui

Line 
1 import java.awt.event.ActionEvent;
2 import java.awt.event.ActionListener;
3 import java.util.ArrayList;
4
5 import javax.swing.*;
6
7 /**
8  * Little GUI to shake the Z axis on the
9  * oswald interface, even if we are running
10  * on a computer, not the oswald.
11  * @author goskab
12  *
13  */
14 public class OswaldInterfaceTest extends JFrame {
15         JButton toggle;
16         ArrayList<Integer> list;
17         /**
18          * makes a new oswald interface tester
19          * allows you to simulate shaking the
20          * oswald.
21          */
22         public OswaldInterfaceTest(ArrayList<Integer> l) {
23                 this.setLayout(null);
24                 this.setSize(130, 100);
25                
26                 toggle = new JButton("Shake It");
27                 this.add(toggle);
28                 toggle.setSize(100,50);
29                 toggle.setLocation(10,10);
30                 toggle.setVisible(true);
31                 toggle.addActionListener(new Shaker());
32                
33                 this.setVisible(true);
34                 list = l;
35                 for (int i = 0; i < 5; i++)
36                         list.add(0);
37         }
38        
39         public class Shaker implements ActionListener {
40                 public void actionPerformed(ActionEvent arg0) {
41                         if (list.get(4) == 0)
42                                 list.set(4, 20000);
43                         else
44                                 list.set(4, 0);
45                 }
46         }
47 }