Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package demo.sphinx.helloworld;
- import java.awt.Color;
- import java.awt.EventQueue;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.io.PrintStream;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JOptionPane;
- import javax.swing.JScrollPane;
- import javax.swing.ScrollPaneConstants;
- import javax.swing.SwingConstants;
- import javax.swing.UIManager;
- import javax.swing.JTextArea;
- public class Frame1 {
- JFrame frame;
- private JLabel state;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- Frame1 window = new Frame1(args);
- window.frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the application.
- * @param args
- */
- public Frame1(String[] args) {
- initialize(args);
- }
- /**
- * Initialize the contents of the frame.
- * @param args
- */
- private void initialize(String[] args) {
- frame = new JFrame();
- frame.getContentPane().setForeground(new Color(50, 205, 50));
- frame.setBounds(100, 100, 525, 295);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.getContentPane().setLayout(null);
- JButton btnNewButton = new JButton("Start Recognizing");
- btnNewButton.setBackground(UIManager.getColor("Button.background"));
- btnNewButton.setForeground(new Color(34, 139, 34));
- btnNewButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- state.setText("Listening");
- System.out.println("Started Listening");
- state.setBackground(new Color(51, 204, 0));
- HelloWorld obj = new HelloWorld();
- obj.main(args);
- }
- });
- btnNewButton.setBounds(10, 11, 156, 49);
- frame.getContentPane().add(btnNewButton);
- JButton btnNewButton_1 = new JButton("Stop Recognizing");
- btnNewButton_1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- state.setText("Not listening");
- state.setBackground(new Color(204, 0, 51));
- System.out.println("Stopped Listening");
- }
- });
- btnNewButton_1.setForeground(new Color(204, 0, 0));
- btnNewButton_1.setBackground(UIManager.getColor("Button.background"));
- btnNewButton_1.setBounds(176, 11, 156, 49);
- frame.getContentPane().add(btnNewButton_1);
- JButton btnNewButton_2 = new JButton("Show Commands");
- btnNewButton_2.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- JOptionPane.showMessageDialog(null, "List\n"
- + "One\n"
- + "two");
- }
- });
- btnNewButton_2.setBounds(342, 11, 156, 49);
- frame.getContentPane().add(btnNewButton_2);
- state = new JLabel("Not listening");
- state.setForeground(new Color(255, 255, 255));
- state.setBackground(new Color(204, 0, 51));
- state.setHorizontalAlignment(SwingConstants.CENTER);
- state.setBounds(10, 222, 488, 24);
- state.setOpaque(true);
- frame.getContentPane().add(state);
- JScrollPane scrollPane = new JScrollPane();
- scrollPane.setBounds(10, 66, 488, 145);
- scrollPane.setVerticalScrollBarPolicy ( ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS );
- frame.getContentPane().add(scrollPane);
- JTextArea textArea = new JTextArea();
- textArea.setBounds(10, 72, 488, 139);
- System.setOut(new PrintStream(new Echo(System.out, textArea)));
- scrollPane.setViewportView(textArea);
- frame.getContentPane().add(scrollPane);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement