List of usage examples for javax.swing JButton setEnabled
public void setEnabled(boolean b)
From source file:org.usfirst.frc.team2084.neuralnetwork.RobotHeadingTest.java
/** * /* w ww. j a v a 2s. c o m*/ */ @Override public void run() { try { final DefaultValueDataset headingData = new DefaultValueDataset(0); final DefaultValueDataset desiredHeadingData = new DefaultValueDataset(0); final CompassPlot headingPlot = new CompassPlot(); headingPlot.addDataset(headingData); headingPlot.addDataset(desiredHeadingData); final JFreeChart headingChart = new JFreeChart("Heading", headingPlot); final XYSeries headingTimeSeries = new XYSeries("Heading"); final XYSeriesCollection headingTimeData = new XYSeriesCollection(); headingTimeData.addSeries(headingTimeSeries); final JFreeChart headingTimeChart = ChartFactory.createXYLineChart("Heading vs. Time", "Time", "Heading", headingTimeData, PlotOrientation.VERTICAL, true, true, false); final XYSeries errorTimeSeries = new XYSeries("Error"); final XYSeriesCollection errorTimeData = new XYSeriesCollection(); errorTimeData.addSeries(errorTimeSeries); final JFreeChart errorTimeChart = ChartFactory.createXYLineChart("Error vs. Time", "Time", "Error", errorTimeData, PlotOrientation.VERTICAL, true, true, false); SwingUtilities.invokeAndWait(() -> { final JFrame frame = new JFrame("Charts"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final Container content = frame.getContentPane(); content.setLayout(new BoxLayout(content, BoxLayout.PAGE_AXIS)); final JPanel chartPanel = new JPanel(); chartPanel.setLayout(new GridLayout(2, 2)); content.add(chartPanel); final ChartPanel headingPanel = new ChartPanel(headingChart); chartPanel.add(headingPanel); final ChartPanel headingTimePanel = new ChartPanel(headingTimeChart); chartPanel.add(headingTimePanel); final ChartPanel errorTimePanel = new ChartPanel(errorTimeChart); chartPanel.add(errorTimePanel); final JPanel buttonPanel = new JPanel(); content.add(buttonPanel); final JButton startButton = new JButton("Start"); final JButton stopButton = new JButton("Stop"); startButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { stop(); startButton.setEnabled(false); stopButton.setEnabled(true); start(headingData, desiredHeadingData, headingTimeSeries, errorTimeSeries); } }); buttonPanel.add(startButton); stopButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { stop(); startButton.setEnabled(true); stopButton.setEnabled(false); } }); stopButton.setEnabled(false); buttonPanel.add(stopButton); frame.pack(); frame.setVisible(true); }); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.sec.ose.osi.ui.frm.main.identification.JPanIdentifyMain.java
public JPanel getJPanelAutoIdentify() { if (jPanelAutoIdentify == null) { jPanelAutoIdentify = new JPanel(); JButton autoIdentifyButton = new JButton("Auto Identify from SPDX"); autoIdentifyButton.setEnabled(false); autoIdentifyButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { JDlgImportSPDX.getInstance().setVisible(true); }// w w w . j a v a2 s .c o m }); jPanelAutoIdentify.add(autoIdentifyButton); IdentifyMediator.getInstance().setAutoIdentifyButton(autoIdentifyButton); } return jPanelAutoIdentify; }
From source file:org.eobjects.datacleaner.widgets.result.PatternFinderResultSwingRendererCrosstabDelegate.java
@Override protected void decorate(CrosstabResult result, DCTable table, DisplayChartCallback displayChartCallback) { super.decorate(result, table, displayChartCallback); table.setAlignment(1, Alignment.RIGHT); final int rowCount = table.getRowCount(); for (int i = 0; i < rowCount; i++) { final Object expressionObject = table.getValueAt(i, 0); final String label = extractString(expressionObject); final String expression = extractExpression(label); final String stringPatternName = "PF: " + label; if (!_catalog.containsStringPattern(stringPatternName)) { DCPanel panel = new DCPanel(); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); panel.add(Box.createHorizontalStrut(4)); panel.add(new JLabel(label)); final JButton button = WidgetFactory.createSmallButton("images/actions/save.png"); button.setToolTipText("Save as string pattern"); button.addActionListener(new ActionListener() { @Override/* w w w . j ava2s . com*/ public void actionPerformed(ActionEvent e) { _catalog.addStringPattern(new SimpleStringPattern(stringPatternName, expression)); button.setEnabled(false); } }); panel.add(Box.createHorizontalStrut(4)); panel.add(button); table.setValueAt(panel, i, 0); } } if (isInitiallyCharted(table)) { displayChart(table, displayChartCallback); } }
From source file:org.datacleaner.widgets.result.PatternFinderResultSwingRendererCrosstabDelegate.java
@Override protected void decorate(CrosstabResult result, DCTable table, DisplayChartCallback displayChartCallback) { super.decorate(result, table, displayChartCallback); table.setAlignment(1, Alignment.RIGHT); final int rowCount = table.getRowCount(); for (int i = 0; i < rowCount; i++) { final Object expressionObject = table.getValueAt(i, 0); final String label = extractString(expressionObject); final String expression = extractExpression(label); final String stringPatternName = "PF: " + label; if (!_catalog.containsStringPattern(stringPatternName)) { DCPanel panel = new DCPanel(); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); panel.add(Box.createHorizontalStrut(4)); panel.add(new JLabel(label)); final JButton button = WidgetFactory.createSmallButton(IconUtils.ACTION_SAVE_DARK); button.setToolTipText("Save as string pattern"); button.addActionListener(new ActionListener() { @Override/* ww w .j av a 2 s. c o m*/ public void actionPerformed(ActionEvent e) { _catalog.addStringPattern(new SimpleStringPattern(stringPatternName, expression)); button.setEnabled(false); } }); panel.add(Box.createHorizontalStrut(4)); panel.add(button); table.setValueAt(panel, i, 0); } } if (isInitiallyCharted(table)) { displayChart(table, displayChartCallback); } }
From source file:fr.free.hd.servers.gui.FaceView.java
@Override protected JComponent createControl() { final GridBagLayout layout = new GridBagLayout(); final JPanel view = new JPanel(layout); //Face list/* w w w . j a v a 2 s.c o m*/ GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.gridheight = 3; c.weighty = 0.75; c.weightx = 0.15; c.fill = GridBagConstraints.BOTH; final JList facesList = CreateList(); facesList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting() == false) { if (facesList.getSelectedIndex() != -1) { face = (Face) facesList.getSelectedValue(); updateLabel(); } else { } } } }); view.add(facesList, c); // New button c = new GridBagConstraints(); c.gridx = 0; c.gridy = 3; c.fill = GridBagConstraints.BOTH; JButton btnNew = new JButton("Nouveau"); btnNew.setEnabled(false); view.add(btnNew, c); // Save button c = new GridBagConstraints(); c.gridx = 0; c.gridy = 4; c.fill = GridBagConstraints.BOTH; JButton btnModified = new JButton("Modifier"); btnModified.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { facesDAO.storeFace(face); } }); view.add(btnModified, c); //Draw Face c = new GridBagConstraints(); c.gridx = 1; c.gridy = 0; c.gridheight = 5; c.gridwidth = 1; c.fill = GridBagConstraints.BOTH; c.weightx = 0.60; lblFace = new JLabel(); view.add(lblFace, c); //Hand Panel c = new GridBagConstraints(); c.gridx = 2; c.gridy = 0; c.weightx = 0.15; c.fill = GridBagConstraints.BOTH; JPanel pnlHand = createPosition(); view.add(pnlHand, c); //Mouth Panel c = new GridBagConstraints(); c.gridx = 2; c.gridy = 1; c.weightx = 0.15; c.fill = GridBagConstraints.BOTH; JPanel pnlKind = createKind(); view.add(pnlKind, c); //Mouth Panel c = new GridBagConstraints(); c.gridx = 2; c.gridy = 2; c.weightx = 0.15; c.fill = GridBagConstraints.BOTH; JPanel pnlMouth = createMouth(); view.add(pnlMouth, c); // Picture filename c = new GridBagConstraints(); c.gridx = 0; c.gridy = 5; c.gridwidth = 2; c.fill = GridBagConstraints.BOTH; JTextField txtPath = new JTextField(); view.add(txtPath, c); //Browse Button c = new GridBagConstraints(); c.gridx = 2; c.gridy = 5; c.fill = GridBagConstraints.BOTH; JButton btnBrownse = new JButton("Browse"); view.add(btnBrownse, c); //Select default face if (facesList.getModel().getSize() > 0) { facesList.setSelectedIndex(0); position = HandPositionEnum.HAND_POSITION_MENTON; kind = HandKeyEnum.HAND_KEY_2V; } return view; }
From source file:net.sf.taverna.t2.workbench.views.results.processor.RenderedProcessorResultComponent.java
/** * Creates the component./*from w w w. j a v a 2s . com*/ */ public RenderedProcessorResultComponent(RendererRegistry rendererRegistry, List<SaveIndividualResultSPI> saveActions) { this.rendererRegistry = rendererRegistry; setLayout(new BorderLayout()); setBorder(new EtchedBorder()); // Results type combo box renderersComboBox = new JComboBox<>(); renderersComboBox.setModel(new DefaultComboBoxModel<String>()); // initially empty renderersComboBox.setRenderer(new ColorCellRenderer()); renderersComboBox.setEditable(false); renderersComboBox.setEnabled(false); // initially disabled // Set the new listener - listen for changes in the currently selected renderer renderersComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == SELECTED && !ERROR_DOCUMENT.equals(e.getItem())) // render the result using the newly selected renderer renderResult(); } }); JPanel resultsTypePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); resultsTypePanel.add(new JLabel("Value type")); resultsTypePanel.add(renderersComboBox); // Refresh (re-render) button refreshButton = new JButton("Refresh", refreshIcon); refreshButton.setEnabled(false); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { renderResult(); refreshButton.getParent().requestFocusInWindow(); /* * so that the button does not stay focused after it is clicked * on and did its action */ } }); resultsTypePanel.add(refreshButton); // Check box for wrapping text if result is of type "text/plain" wrapTextCheckBox = new JCheckBox(WRAP_TEXT); wrapTextCheckBox.setVisible(false); wrapTextCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { // Should have only one child component holding the rendered result // Check for empty just as well if (renderedResultPanel.getComponents().length == 0) return; if (renderedResultPanel.getComponent(0) instanceof DialogTextArea) { nodeToWrapSelection.put(node.hashCode(), e.getStateChange() == SELECTED); renderResult(); } } }); resultsTypePanel.add(wrapTextCheckBox); // 'Save result' buttons panel saveButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); for (SaveIndividualResultSPI action : saveActions) { action.setResultReference(null); final JButton saveButton = new JButton(action.getAction()); saveButton.setEnabled(false); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveButton.getParent().requestFocusInWindow(); /* * so that the button does not stay focused after it is * clicked on and did its action */ } }); saveButtonsPanel.add(saveButton); } // Top panel contains result type combobox and various save buttons JPanel topPanel = new JPanel(); topPanel.setLayout(new BoxLayout(topPanel, LINE_AXIS)); topPanel.add(resultsTypePanel); topPanel.add(saveButtonsPanel); // Rendered results panel - initially empty renderedResultPanel = new JPanel(new BorderLayout()); renderedResultPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); // Add all components add(topPanel, NORTH); add(new JScrollPane(renderedResultPanel), CENTER); }
From source file:net.sf.taverna.t2.workbench.views.results.workflow.RenderedResultComponent.java
/** * Creates the component.//from w w w .j ava2 s .c om */ public RenderedResultComponent(RendererRegistry rendererRegistry, List<SaveIndividualResultSPI> saveActions) { this.rendererRegistry = rendererRegistry; setLayout(new BorderLayout()); // Results type combo box renderersComboBox = new JComboBox<>(); renderersComboBox.setModel(new DefaultComboBoxModel<String>()); // initially empty renderersComboBox.setRenderer(new ColorCellRenderer()); renderersComboBox.setEditable(false); renderersComboBox.setEnabled(false); // initially disabled // Set the new listener - listen for changes in the currently selected renderer renderersComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED && !ERROR_DOCUMENT.equals(e.getItem())) // render the result using the newly selected renderer renderResult(); } }); JPanel resultsTypePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); resultsTypePanel.add(new JLabel("Value type")); resultsTypePanel.add(renderersComboBox); // Refresh (re-render) button refreshButton = new JButton("Refresh", refreshIcon); refreshButton.setEnabled(false); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { renderResult(); refreshButton.getParent().requestFocusInWindow(); /* * so that the button does not stay focused after it is clicked * on and did its action */ } }); resultsTypePanel.add(refreshButton); // Check box for wrapping text if result is of type "text/plain" wrapTextCheckBox = new JCheckBox(WRAP_TEXT); wrapTextCheckBox.setVisible(false); wrapTextCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { // Should have only one child component holding the rendered result // Check for empty just as well if (renderedResultPanel.getComponents().length == 0) return; Component component = renderedResultPanel.getComponent(0); if (component instanceof DialogTextArea) { nodeToWrapSelection.put(path, e.getStateChange() == SELECTED); renderResult(); } } }); resultsTypePanel.add(wrapTextCheckBox); // 'Save result' buttons panel saveButtonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); for (SaveIndividualResultSPI action : saveActions) { action.setResultReference(null); final JButton saveButton = new JButton(action.getAction()); saveButton.setEnabled(false); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveButton.getParent().requestFocusInWindow(); /* * so that the button does not stay focused after it is * clicked on and did its action */ } }); saveButtonsPanel.add(saveButton); } // Top panel contains result type combobox and various save buttons JPanel topPanel = new JPanel(); topPanel.setLayout(new BoxLayout(topPanel, LINE_AXIS)); topPanel.add(resultsTypePanel); topPanel.add(saveButtonsPanel); // Rendered results panel - initially empty renderedResultPanel = new JPanel(new BorderLayout()); // Add all components add(topPanel, NORTH); add(new JScrollPane(renderedResultPanel), CENTER); }
From source file:net.sf.taverna.t2.workbench.views.results.processor.RenderedProcessorResultComponent.java
/** * Clears the result panel.//from w w w .j a va 2 s. c om */ public void clearResult() { refreshButton.setEnabled(false); renderedResultPanel.removeAll(); // Update the 'save result' buttons appropriately for (int i = 0; i < saveButtonsPanel.getComponents().length; i++) { JButton saveButton = (JButton) saveButtonsPanel.getComponent(i); SaveIndividualResultSPI action = (SaveIndividualResultSPI) (saveButton.getAction()); // Update the action action.setResultReference(null); saveButton.setEnabled(false); } renderersComboBox.setModel(new DefaultComboBoxModel<String>()); renderersComboBox.setEnabled(false); revalidate(); repaint(); }
From source file:DesktopAppTest.java
public DesktopAppFrame() { setLayout(new GridBagLayout()); final JFileChooser chooser = new JFileChooser(); JButton fileChooserButton = new JButton("..."); final JTextField fileField = new JTextField(20); fileField.setEditable(false);/*from ww w. j a v a2 s. com*/ JButton openButton = new JButton("Open"); JButton editButton = new JButton("Edit"); JButton printButton = new JButton("Print"); final JTextField browseField = new JTextField(); JButton browseButton = new JButton("Browse"); final JTextField toField = new JTextField(); final JTextField subjectField = new JTextField(); JButton mailButton = new JButton("Mail"); openButton.setEnabled(false); editButton.setEnabled(false); printButton.setEnabled(false); browseButton.setEnabled(false); mailButton.setEnabled(false); if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) openButton.setEnabled(true); if (desktop.isSupported(Desktop.Action.EDIT)) editButton.setEnabled(true); if (desktop.isSupported(Desktop.Action.PRINT)) printButton.setEnabled(true); if (desktop.isSupported(Desktop.Action.BROWSE)) browseButton.setEnabled(true); if (desktop.isSupported(Desktop.Action.MAIL)) mailButton.setEnabled(true); } fileChooserButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (chooser.showOpenDialog(DesktopAppFrame.this) == JFileChooser.APPROVE_OPTION) fileField.setText(chooser.getSelectedFile().getAbsolutePath()); } }); openButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Desktop.getDesktop().open(chooser.getSelectedFile()); } catch (IOException ex) { ex.printStackTrace(); } } }); editButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Desktop.getDesktop().edit(chooser.getSelectedFile()); } catch (IOException ex) { ex.printStackTrace(); } } }); printButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Desktop.getDesktop().print(chooser.getSelectedFile()); } catch (IOException ex) { ex.printStackTrace(); } } }); browseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Desktop.getDesktop().browse(new URI(browseField.getText())); } catch (URISyntaxException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } } }); mailButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { String subject = percentEncode(subjectField.getText()); URI uri = new URI("mailto:" + toField.getText() + "?subject=" + subject); System.out.println(uri); Desktop.getDesktop().mail(uri); } catch (URISyntaxException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } } }); JPanel buttonPanel = new JPanel(); ((FlowLayout) buttonPanel.getLayout()).setHgap(2); buttonPanel.add(openButton); buttonPanel.add(editButton); buttonPanel.add(printButton); add(fileChooserButton, new GBC(0, 0).setAnchor(GBC.EAST).setInsets(2)); add(fileField, new GBC(1, 0).setFill(GBC.HORIZONTAL)); add(buttonPanel, new GBC(2, 0).setAnchor(GBC.WEST).setInsets(0)); add(browseField, new GBC(1, 1).setFill(GBC.HORIZONTAL)); add(browseButton, new GBC(2, 1).setAnchor(GBC.WEST).setInsets(2)); add(new JLabel("To:"), new GBC(0, 2).setAnchor(GBC.EAST).setInsets(5, 2, 5, 2)); add(toField, new GBC(1, 2).setFill(GBC.HORIZONTAL)); add(mailButton, new GBC(2, 2).setAnchor(GBC.WEST).setInsets(2)); add(new JLabel("Subject:"), new GBC(0, 3).setAnchor(GBC.EAST).setInsets(5, 2, 5, 2)); add(subjectField, new GBC(1, 3).setFill(GBC.HORIZONTAL)); pack(); }
From source file:net.sf.taverna.t2.workbench.views.results.workflow.RenderedResultComponent.java
/** * Clears the result panel./*from www . j a va 2 s . co m*/ */ public void clearResult() { refreshButton.setEnabled(false); wrapTextCheckBox.setVisible(false); renderedResultPanel.removeAll(); // Update the 'save result' buttons appropriately for (int i = 0; i < saveButtonsPanel.getComponents().length; i++) { JButton saveButton = (JButton) saveButtonsPanel.getComponent(i); SaveIndividualResultSPI action = (SaveIndividualResultSPI) saveButton.getAction(); // Update the action action.setResultReference(null); saveButton.setEnabled(false); } renderersComboBox.setModel(new DefaultComboBoxModel<String>()); renderersComboBox.setEnabled(false); revalidate(); repaint(); }