Java Code Examples for javax.swing.JToggleButton#setRequestFocusEnabled()
The following examples show how to use
javax.swing.JToggleButton#setRequestFocusEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GUIFrame.java From jaamsim with Apache License 2.0 | 6 votes |
private void add2dButton(JToolBar buttonBar, Insets margin) { lockViewXYPlane = new JToggleButton( "2D" ); lockViewXYPlane.setMargin(margin); lockViewXYPlane.setFocusPainted(false); lockViewXYPlane.setRequestFocusEnabled(false); lockViewXYPlane.setToolTipText(formatToolTip("2D View", "Sets the camera position to show a bird's eye view of the 3D scene.")); lockViewXYPlane.addActionListener( new ActionListener() { @Override public void actionPerformed( ActionEvent event ) { boolean bLock2D = (((JToggleButton)event.getSource()).isSelected()); if (RenderManager.isGood()) { View currentView = RenderManager.inst().getActiveView(); if (currentView != null) { currentView.setLock2D(bLock2D); } } controlStartResume.requestFocusInWindow(); } } ); buttonBar.add( lockViewXYPlane ); }
Example 2
Source File: GUIFrame.java From jaamsim with Apache License 2.0 | 6 votes |
private void addShowAxesButton(JToolBar buttonBar, Insets margin) { xyzAxis = new JToggleButton( new ImageIcon( GUIFrame.class.getResource("/resources/images/Axes-16.png")) ); xyzAxis.setMargin(margin); xyzAxis.setFocusPainted(false); xyzAxis.setRequestFocusEnabled(false); xyzAxis.setToolTipText(formatToolTip("Show Axes", "Shows the unit vectors for the x, y, and z axes.")); xyzAxis.addActionListener( new ActionListener() { @Override public void actionPerformed( ActionEvent event ) { DisplayEntity ent = (DisplayEntity) sim.getNamedEntity("XYZ-Axis"); if (ent != null) { KeywordIndex kw = InputAgent.formatBoolean("Show", xyzAxis.isSelected()); InputAgent.storeAndExecute(new KeywordCommand(ent, kw)); } controlStartResume.requestFocusInWindow(); } } ); buttonBar.add( xyzAxis ); }
Example 3
Source File: GUIFrame.java From jaamsim with Apache License 2.0 | 6 votes |
private void addShowLabelsButton(JToolBar buttonBar, Insets margin) { showLabels = new JToggleButton( new ImageIcon( GUIFrame.class.getResource("/resources/images/ShowLabels-16.png")) ); showLabels.setMargin(margin); showLabels.setFocusPainted(false); showLabels.setRequestFocusEnabled(false); showLabels.setToolTipText(formatToolTip("Show Labels", "Displays the label for every entity in the model.")); showLabels.addActionListener( new ActionListener() { @Override public void actionPerformed( ActionEvent event ) { boolean bool = showLabels.isSelected(); KeywordIndex kw = InputAgent.formatBoolean("ShowLabels", bool); InputAgent.storeAndExecute(new KeywordCommand(sim.getSimulation(), kw)); setShowLabels(bool); controlStartResume.requestFocusInWindow(); } } ); buttonBar.add( showLabels ); }
Example 4
Source File: GUIFrame.java From jaamsim with Apache License 2.0 | 6 votes |
private void addShowSubModelsButton(JToolBar buttonBar, Insets margin) { showSubModels = new JToggleButton( new ImageIcon( GUIFrame.class.getResource("/resources/images/ShowSubModels-16.png")) ); showSubModels.setMargin(margin); showSubModels.setFocusPainted(false); showSubModels.setRequestFocusEnabled(false); showSubModels.setToolTipText(formatToolTip("Show SubModels", "Displays the components of each sub-model.")); showSubModels.addActionListener( new ActionListener() { @Override public void actionPerformed( ActionEvent event ) { boolean bool = showSubModels.isSelected(); KeywordIndex kw = InputAgent.formatBoolean("ShowSubModels", bool); InputAgent.storeAndExecute(new KeywordCommand(sim.getSimulation(), kw)); setShowSubModels(bool); controlStartResume.requestFocusInWindow(); } } ); buttonBar.add( showSubModels ); }
Example 5
Source File: GUIFrame.java From jaamsim with Apache License 2.0 | 6 votes |
private void addSnapToGridButton(JToolBar buttonBar, Insets margin) { snapToGrid = new JToggleButton( new ImageIcon( GUIFrame.class.getResource("/resources/images/Snap-16.png")) ); snapToGrid.setMargin(margin); snapToGrid.setFocusPainted(false); snapToGrid.setRequestFocusEnabled(false); snapToGrid.setToolTipText(formatToolTip("Snap to Grid", "During repositioning, objects are forced to the nearest grid point.")); snapToGrid.addActionListener( new ActionListener() { @Override public void actionPerformed( ActionEvent event ) { KeywordIndex kw = InputAgent.formatBoolean("SnapToGrid", snapToGrid.isSelected()); InputAgent.storeAndExecute(new KeywordCommand(sim.getSimulation(), kw)); gridSpacing.setEnabled(snapToGrid.isSelected()); controlStartResume.requestFocusInWindow(); } } ); buttonBar.add( snapToGrid ); }
Example 6
Source File: GUIFrame.java From jaamsim with Apache License 2.0 | 6 votes |
private void addShowLinksButton(JToolBar buttonBar, Insets margin) { showLinks = new JToggleButton(new ImageIcon(GUIFrame.class.getResource("/resources/images/ShowLinks-16.png"))); showLinks.setToolTipText(formatToolTip("Show Entity Flow", "When selected, arrows are shown between objects to indicate the flow of entities.")); showLinks.setMargin(margin); showLinks.setFocusPainted(false); showLinks.setRequestFocusEnabled(false); showLinks.addActionListener(new ActionListener() { @Override public void actionPerformed( ActionEvent event ) { boolean bShow = (((JToggleButton)event.getSource()).isSelected()); if (RenderManager.isGood()) { RenderManager.inst().setShowLinks(bShow); RenderManager.redraw(); } controlStartResume.requestFocusInWindow(); } }); buttonBar.add( showLinks ); }
Example 7
Source File: GUIFrame.java From jaamsim with Apache License 2.0 | 6 votes |
private void addReverseButton(JToolBar buttonBar, Insets margin) { reverseButton = new JToggleButton(new ImageIcon(GUIFrame.class.getResource("/resources/images/Reverse-16.png"))); reverseButton.setToolTipText(formatToolTip("Reverse Direction", "When enabled, the link arrows are shown for entities travelling in the reverse " + "direction, and the Next and Previous buttons select the next/previous links " + "for that direction.")); reverseButton.setMargin(margin); reverseButton.setFocusPainted(false); reverseButton.setRequestFocusEnabled(false); reverseButton.addActionListener(new ActionListener() { @Override public void actionPerformed( ActionEvent event ) { if (createLinks.isSelected()) createLinks.doClick(); boolean bool = (((JToggleButton)event.getSource()).isSelected()); if (RenderManager.isGood()) { RenderManager.inst().setLinkDirection(!bool); RenderManager.redraw(); } updateUI(); } }); // Reverse button is not needed in the open source JaamSim //buttonBar.add( reverseButton ); }
Example 8
Source File: GUIFrame.java From jaamsim with Apache License 2.0 | 6 votes |
private void addEntityFinderButton(JToolBar buttonBar, Insets margin) { find = new JToggleButton(new ImageIcon(GUIFrame.class.getResource("/resources/images/Find-16.png"))); find.setToolTipText(formatToolTip("Entity Finder (Ctrl+F)", "Searches for an entity with a given name.")); find.setMargin(margin); find.setFocusPainted(false); find.setRequestFocusEnabled(false); find.addActionListener(new ActionListener() { @Override public void actionPerformed( ActionEvent event ) { if (find.isSelected()) { FindBox.getInstance().showDialog(); } else { FindBox.getInstance().setVisible(false); } controlStartResume.requestFocusInWindow(); } }); buttonBar.add( find ); }
Example 9
Source File: GUIFrame.java From jaamsim with Apache License 2.0 | 6 votes |
private void addOutlineButton(JToolBar buttonBar, Insets margin) { outline = new JToggleButton(new ImageIcon( GUIFrame.class.getResource("/resources/images/Outline-16.png"))); outline.setMargin(margin); outline.setFocusPainted(false); outline.setRequestFocusEnabled(false); outline.setToolTipText(formatToolTip("Show Outline", "Shows the outline.")); outline.addActionListener( new ActionListener() { @Override public void actionPerformed( ActionEvent event ) { if (!(selectedEntity instanceof LineEntity)) return; LineEntity lineEnt = (LineEntity) selectedEntity; lineWidth.setEnabled(outline.isSelected()); lineColour.setEnabled(outline.isSelected()); if (lineEnt.isOutlined() == outline.isSelected()) return; KeywordIndex kw = InputAgent.formatBoolean("Outlined", outline.isSelected()); InputAgent.storeAndExecute(new KeywordCommand((Entity)lineEnt, kw)); controlStartResume.requestFocusInWindow(); } }); buttonBar.add( outline ); }
Example 10
Source File: GUIFrame.java From jaamsim with Apache License 2.0 | 6 votes |
private void addFillButton(JToolBar buttonBar, Insets margin) { fill = new JToggleButton(new ImageIcon( GUIFrame.class.getResource("/resources/images/Fill-16.png"))); fill.setMargin(margin); fill.setFocusPainted(false); fill.setRequestFocusEnabled(false); fill.setToolTipText(formatToolTip("Show Fill", "Fills the entity with the selected colour.")); fill.addActionListener( new ActionListener() { @Override public void actionPerformed( ActionEvent event ) { if (!(selectedEntity instanceof FillEntity)) return; FillEntity fillEnt = (FillEntity) selectedEntity; fillColour.setEnabled(fill.isSelected()); if (fillEnt.isFilled() == fill.isSelected()) return; KeywordIndex kw = InputAgent.formatBoolean("Filled", fill.isSelected()); InputAgent.storeAndExecute(new KeywordCommand((Entity)fillEnt, kw)); controlStartResume.requestFocusInWindow(); } }); buttonBar.add( fill ); }
Example 11
Source File: GUIFrame.java From jaamsim with Apache License 2.0 | 6 votes |
private void addRealTimeButton(JToolBar mainToolBar, Insets margin) { controlRealTime = new JToggleButton( " Real Time " ); controlRealTime.setToolTipText(formatToolTip("Real Time Mode", "When selected, the simulation runs at a fixed multiple of wall clock time.")); controlRealTime.setMargin(margin); controlRealTime.setFocusPainted(false); controlRealTime.setRequestFocusEnabled(false); controlRealTime.addActionListener(new ActionListener() { @Override public void actionPerformed( ActionEvent event ) { boolean bool = ((JToggleButton)event.getSource()).isSelected(); KeywordIndex kw = InputAgent.formatBoolean("RealTime", bool); InputAgent.storeAndExecute(new KeywordCommand(sim.getSimulation(), kw)); controlStartResume.requestFocusInWindow(); } }); mainToolBar.add( controlRealTime ); }
Example 12
Source File: PaletteUI.java From pumpernickel with MIT License | 5 votes |
private JToggleButton createCell() { JToggleButton newCell = new JToggleButton(); newCell.addMouseListener(mouseListener); newCell.addMouseMotionListener(mouseListener); newCell.setContentAreaFilled(false); newCell.setBorder(null); newCell.setRequestFocusEnabled(false); newCell.setBorderPainted(false); newCell.setOpaque(false); newCell.putClientProperty(PROPERTY_CELL, Boolean.TRUE); newCell.addActionListener(cellActionListener); return newCell; }
Example 13
Source File: GUIFrame.java From jaamsim with Apache License 2.0 | 5 votes |
private void addShowGridButton(JToolBar buttonBar, Insets margin) { grid = new JToggleButton( new ImageIcon( GUIFrame.class.getResource("/resources/images/Grid-16.png")) ); grid.setMargin(margin); grid.setFocusPainted(false); grid.setRequestFocusEnabled(false); grid.setToolTipText(formatToolTip("Show Grid", "Shows the coordinate grid on the x-y plane.")); grid.addActionListener( new ActionListener() { @Override public void actionPerformed( ActionEvent event ) { DisplayEntity ent = (DisplayEntity) sim.getNamedEntity("XY-Grid"); if (ent == null && sim.getNamedEntity("Grid100x100") != null) { InputAgent.storeAndExecute(new DefineCommand(sim, DisplayEntity.class, "XY-Grid")); ent = (DisplayEntity) sim.getNamedEntity("XY-Grid"); KeywordIndex dmKw = InputAgent.formatArgs("DisplayModel", "Grid100x100"); KeywordIndex sizeKw = InputAgent.formatArgs("Size", "100", "100", "0", "m"); InputAgent.storeAndExecute(new KeywordCommand(ent, dmKw, sizeKw)); grid.setSelected(true); } if (ent != null) { KeywordIndex kw = InputAgent.formatBoolean("Show", grid.isSelected()); InputAgent.storeAndExecute(new KeywordCommand(ent, kw)); } controlStartResume.requestFocusInWindow(); } } ); buttonBar.add( grid ); }
Example 14
Source File: GUIFrame.java From jaamsim with Apache License 2.0 | 5 votes |
private void addCreateLinksButton(JToolBar buttonBar, Insets margin) { createLinks = new JToggleButton(new ImageIcon(GUIFrame.class.getResource("/resources/images/MakeLinks-16.png"))); createLinks.setToolTipText(formatToolTip("Create Entity Links", "When this is enabled, entities are linked when selection is changed.")); createLinks.setMargin(margin); createLinks.setFocusPainted(false); createLinks.setRequestFocusEnabled(false); createLinks.addActionListener(new ActionListener() { @Override public void actionPerformed( ActionEvent event ) { boolean bCreate = (((JToggleButton)event.getSource()).isSelected()); if (RenderManager.isGood()) { if (bCreate) { FrameBox.setSelectedEntity(null, false); showLinks.setSelected(true); RenderManager.inst().setShowLinks(true); } RenderManager.inst().setCreateLinks(bCreate); RenderManager.redraw(); } controlStartResume.requestFocusInWindow(); } }); buttonBar.add( createLinks ); }