List of usage examples for javax.swing JCheckBoxMenuItem getText
public String getText()
From source file:org.tros.torgo.ControllerBase.java
/** * Instantiate/Run the interpreter.// ww w . j a v a 2 s . c om */ @Override public void startInterpreter() { String source = torgoPanel.getSource(); interp = createInterpreterThread(source); for (JCheckBoxMenuItem item : viz) { if (item.getState()) { TorgoToolkit.getVisualization(item.getText()).create().watch(this.getLang(), this, interp); } } // viz.stream().filter((item) -> (item.getState())).map((item) -> TorgoToolkit.getVisualization(item.getText()).create()).forEach((visualization) -> { // visualization.watch(this.getLang(), this, interp); // }); for (InterpreterListener l : listeners.getListeners()) { interp.addInterpreterListener(l); } interp.addInterpreterListener(new InterpreterListener() { @Override public void started() { } @Override public void finished() { } @Override public void error(Exception e) { org.tros.utils.logging.Logging.getLogFactory().getLogger(ControllerBase.class).fatal(null, e); } @Override public void message(String msg) { torgoPanel.appendToOutputTextArea(msg); } @Override public void currStatement(CodeBlock block, Scope scope) { } }); controllerListeners.fire().onStartInterpreter(); interp.start(); }
From source file:org.tros.torgo.ControllerBase.java
/** * Instantiate an interpreter in debug mode. *///from w ww . j ava2s . co m @Override public void debugInterpreter() { String source = torgoPanel.getSource(); interp = createInterpreterThread(source); step.reset(); for (JCheckBoxMenuItem item : viz) { if (item.getState()) { TorgoToolkit.getVisualization(item.getText()).create().watch(this.getLang(), this, interp); } } // viz.stream().filter((item) -> (item.getState())).map((item) -> TorgoToolkit.getVisualization(item.getText()).create()).forEach((visualization) -> { // visualization.watch(this.getLang(), this, interp); // }); for (InterpreterListener l : listeners.getListeners()) { interp.addInterpreterListener(l); } interp.addInterpreterListener(new InterpreterListener() { @Override public void started() { } @Override public void finished() { torgoPanel.highlight(-1, 0, 0); } @Override public void error(Exception e) { org.tros.utils.logging.Logging.getLogFactory().getLogger(ControllerBase.class).fatal(null, e); } @Override public void message(String msg) { torgoPanel.appendToOutputTextArea(msg); } @Override public void currStatement(CodeBlock block, Scope scope) { try { if (isStepping.get()) { step.waitOne(); } //TODO: this needs to be configurable Thread.sleep(100); } catch (InterruptedException ex) { org.tros.utils.logging.Logging.getLogFactory().getLogger(ControllerBase.class).fatal(null, ex); } int line = block.getParserRuleContext().getStart().getLine(); int start = block.getParserRuleContext().getStart().getStartIndex(); int end = block.getParserRuleContext().getStart().getStopIndex(); torgoPanel.highlight(line, start, end); } }); controllerListeners.fire().onDebugInterpreter(); interp.start(); }
From source file:processing.app.Editor.java
protected void selectSerialPort(String name) { if (serialMenu == null) { System.out.println(_("serialMenu is null")); return;/*from w w w . j a va 2 s .c om*/ } if (name == null) { System.out.println(_("name is null")); return; } JCheckBoxMenuItem selection = null; for (int i = 0; i < serialMenu.getItemCount(); i++) { JMenuItem menuItem = serialMenu.getItem(i); if (!(menuItem instanceof JCheckBoxMenuItem)) { continue; } JCheckBoxMenuItem checkBoxMenuItem = ((JCheckBoxMenuItem) menuItem); if (checkBoxMenuItem == null) { System.out.println(_("name is null")); continue; } checkBoxMenuItem.setState(false); if (name.equals(checkBoxMenuItem.getText())) selection = checkBoxMenuItem; } if (selection != null) selection.setState(true); //System.out.println(item.getLabel()); BaseNoGui.selectSerialPort(name); if (serialMonitor != null) { try { serialMonitor.close(); serialMonitor.setVisible(false); } catch (Exception e) { // ignore } } onBoardOrPortChange(); //System.out.println("set to " + get("serial.port")); }
From source file:savant.view.swing.FrameCommandBar.java
/** * Create display menu for commandBar//from www. ja va 2 s. c o m */ private JMenu createDisplayModeMenu() { JMenu menu = new JMenu("Display Mode"); //display modes DrawingMode[] validModes = mainTrack.getValidDrawingModes(); modeItems = new JCheckBoxMenuItem[validModes.length]; for (int i = 0; i < validModes.length; i++) { JCheckBoxMenuItem item = new JCheckBoxMenuItem(validModes[i].getDescription()); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JCheckBoxMenuItem item = (JCheckBoxMenuItem) e.getSource(); if (item.getState()) { DrawingMode[] validModes = mainTrack.getValidDrawingModes(); for (int j = 0; j < modeItems.length; j++) { if (item.getText().equals(validModes[j].getDescription())) { for (TrackAdapter t : frame.getTracks()) { AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("track-event", "DisplayModeChanged"), new NameValuePair("track-type", t.getClass().getSimpleName()), new NameValuePair("target-mode", validModes[j].getDescription()) }); t.setDrawingMode(validModes[j]); } drawModePosition = j; } else { modeItems[j].setState(false); } } } else { item.setState(true); } } }); if (validModes[i] == mainTrack.getDrawingMode()) { item.setState(true); } modeItems[i] = item; menu.add(item); } // Determine position of current draw mode. DrawingMode currentMode = mainTrack.getDrawingMode(); for (int i = 0; i < validModes.length; i++) { if (validModes[i].equals(currentMode)) { drawModePosition = i; break; } } // Allow cycling through display modes. graphPane.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { //check for: Mac + Command + 'm' OR !Mac + Ctrl + 'm' if ((MiscUtils.MAC && e.getModifiersEx() == 256 && e.getKeyChar() == 'm') || (!MiscUtils.MAC && e.getKeyChar() == '\n' && e.isControlDown())) { cycleDisplayMode(); } } }); return menu; }