Instantly share code, notes, and snippets.
Last active
December 15, 2015 02:39
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
Save TheBatScripts/5188652 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void makeMenuBar() { | |
| JMenu script = new JMenu("Script"); | |
| script.add(start); | |
| script.add(pause); | |
| script.add(stop); | |
| script.add(rerun); | |
| menu.add(script); | |
| start.setEnabled(false); | |
| pause.setEnabled(false); | |
| stop.setEnabled(false); | |
| rerun.setEnabled(false); | |
| JMenu tools = new JMenu("Tools"); | |
| JMenuItem mousePos = new JMenuItem("Mouse Position"); | |
| JMenuItem mouseCol = new JMenuItem("Mouse Color"); | |
| JMenuItem mouseCrossHair = new JMenuItem("Mouse Crosshair"); | |
| tools.add(mousePos); | |
| tools.add(mouseCol); | |
| tools.add(mouseCrossHair); | |
| menu.add(tools); | |
| startB.setToolTipText("Start"); | |
| pauseB.setToolTipText("Pause"); | |
| stopB.setToolTipText("Stop"); | |
| rerunB.setToolTipText("Re-Run"); | |
| inputB.setToolTipText("Disable Input"); | |
| startB.setFocusable(false); | |
| pauseB.setFocusable(false); | |
| stopB.setFocusable(false); | |
| rerunB.setFocusable(false); | |
| inputB.setFocusable(false); | |
| startB.setEnabled(false); | |
| pauseB.setEnabled(false); | |
| stopB.setEnabled(false); | |
| rerunB.setEnabled(false); | |
| inputB.setEnabled(false); | |
| startB.setIcon(ico.getStart()); | |
| pauseB.setIcon(ico.getPause()); | |
| stopB.setIcon(ico.getStop()); | |
| rerunB.setIcon(ico.getRerun()); | |
| inputB.setIcon(ico.getKey()); | |
| startB.setHorizontalAlignment(SwingConstants.RIGHT); | |
| pauseB.setFocusable(false); | |
| stopB.setFocusable(false); | |
| rerunB.setFocusable(false); | |
| menu.add(Box.createHorizontalGlue()); | |
| menu.add(startB); | |
| menu.add(pauseB); | |
| menu.add(stopB); | |
| menu.add(rerunB); | |
| menu.add(inputB); | |
| final Client This = this; | |
| //Script menu listeners | |
| start.addActionListener(new ActionListener(){ | |
| @Override | |
| public void actionPerformed(ActionEvent e) { | |
| if(scriptRunner != null && scriptRunner.isPaused()){ | |
| resumeScript(); | |
| }else{ | |
| SwingUtilities.invokeLater(new Runnable() { | |
| public void run() { | |
| new ScriptSelectionGUI(This).setVisible(true); | |
| } | |
| }); | |
| } | |
| } | |
| }); | |
| pause.addActionListener(new ActionListener(){ | |
| @Override | |
| public void actionPerformed(ActionEvent e) { | |
| pauseScript(); | |
| } | |
| }); | |
| stop.addActionListener(new ActionListener(){ | |
| @Override | |
| public void actionPerformed(ActionEvent e) { | |
| stopScript(); | |
| } | |
| }); | |
| rerun.addActionListener(new ActionListener(){ | |
| @Override | |
| public void actionPerformed(ActionEvent e) { | |
| reStartScript(); | |
| } | |
| }); | |
| //Button Listeners | |
| startB.addActionListener(new ActionListener(){ | |
| @Override | |
| public void actionPerformed(ActionEvent e) { | |
| if(scriptRunner != null && scriptRunner.isPaused()){ | |
| resumeScript(); | |
| }else{ | |
| SwingUtilities.invokeLater(new Runnable() { | |
| public void run() { | |
| new ScriptSelectionGUI(This).setVisible(true); | |
| } | |
| }); | |
| } | |
| } | |
| }); | |
| pauseB.addActionListener(new ActionListener(){ | |
| @Override | |
| public void actionPerformed(ActionEvent e) { | |
| pauseScript(); | |
| } | |
| }); | |
| rerunB.addActionListener(new ActionListener(){ | |
| @Override | |
| public void actionPerformed(ActionEvent e) { | |
| reStartScript(); | |
| } | |
| }); | |
| stopB.addActionListener(new ActionListener(){ | |
| @Override | |
| public void actionPerformed(ActionEvent e) { | |
| stopScript(); | |
| } | |
| }); | |
| inputB.addActionListener(new ActionListener(){ | |
| @Override | |
| public void actionPerformed(ActionEvent e) { | |
| if(isInputEnabled()){ | |
| setInputEnabled(false); | |
| inputB.setIcon(ico.getDisKey()); | |
| }else{ | |
| setInputEnabled(true); | |
| inputB.setIcon(ico.getKey()); | |
| } | |
| } | |
| }); | |
| //Tools menu listeners | |
| mousePos.addActionListener(new ActionListener(){ | |
| @Override | |
| public void actionPerformed(ActionEvent e) { | |
| showMouse = !showMouse; | |
| } | |
| }); | |
| mouseCol.addActionListener(new ActionListener(){ | |
| @Override | |
| public void actionPerformed(ActionEvent e) { | |
| showColor = !showColor; | |
| } | |
| }); | |
| mouseCrossHair.addActionListener(new ActionListener(){ | |
| @Override | |
| public void actionPerformed(ActionEvent e) { | |
| showMouseCross = !showMouseCross; | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment