Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.AWTException;
- import java.awt.BorderLayout;
- import java.awt.ComponentOrientation;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.GridLayout;
- import java.awt.Robot;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.InputEvent;
- import java.awt.event.KeyEvent;
- import java.awt.event.KeyListener;
- import java.util.Random;
- import javax.swing.Timer;
- import javax.swing.BorderFactory;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.JTextArea;
- public class robo extends JFrame implements ActionListener
- {
- private JPanel displayPanel;
- JTextArea display = new JTextArea(1,1);
- JTextArea display2 = new JTextArea(1,1);
- JButton GO;
- JButton STOP;
- JLabel FeedBack;
- int video=0;
- int i=0;
- Timer t;//global declaration;
- Robot robot;
- robo() throws Exception
- {
- setSize(250, 180);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setLocation(100, 75);
- setFocusable( true );
- //setResizable(false);
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- setFocusable(true);
- requestFocusInWindow();
- setTitle("!!!Swaggy Hack!!!");
- FeedBack = new JLabel(".");
- displayPanel = new JPanel();
- display.setEditable(true);
- Font font = new Font("Verdana", Font.BOLD, 12);
- display.setFont(font);
- display.setText("1");
- display.setPreferredSize(new Dimension(800,800));
- displayPanel.add(display);
- display2.setEditable(true);
- font = new Font("Verdana", Font.BOLD, 12);
- display2.setFont(font);
- display2.setText("f");
- display2.setPreferredSize(new Dimension(100, 100));
- displayPanel.add(display2);
- GO = new JButton("GO!!!");
- GO.addActionListener(this);
- STOP = new JButton("STOP!!!");
- STOP.addActionListener(this);
- video= Integer.parseInt(display.getText());
- JPanel contentPane = new JPanel(new GridLayout(6,5));
- contentPane.add(display);
- contentPane.add(display2);
- contentPane.add(GO);
- contentPane.add(STOP);
- contentPane.add(FeedBack);
- this.setContentPane(contentPane);
- setVisible(true);
- ////////////////////////////////
- t = new Timer(1000, new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- // robot.delay(3000);
- // FeedBack.setText(null);
- FeedBack.setText("Run"+ i);
- i++;
- // robot.delay(3000);
- // FeedBack.setText(null);
- // FeedBack.setText("Hello World");
- }
- });
- }
- @Override
- public void actionPerformed(ActionEvent event)
- {
- // TODO Auto-generated method stub
- JButton src = (JButton) event.getSource(); //get which button is clicked
- if(src.equals(GO)) //if GO button is clicked
- {
- System.out.println("hi");
- t.start();
- }
- if(src.equals(STOP)) //if STOP button is clicked
- {
- //do nothing
- t.stop();
- FeedBack.setText(null);
- FeedBack.setText("Stopped");
- }
- }
- private void runHack() throws AWTException
- {
- }
- public static void main(String[] args) throws Exception {
- robo robo = new robo();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment