List of usage examples for javax.swing JButton setActionCommand
public void setActionCommand(String actionCommand)
From source file:ch.zhaw.simulation.diagram.charteditor.DefaultPlotEditor.java
/** * Standard constructor - constructs a panel for editing the properties of * the specified plot./* w w w.j a v a 2 s . co m*/ * <P> * In designing the panel, we need to be aware that subclasses of Plot will * need to implement subclasses of PlotPropertyEditPanel - so we need to * leave one or two 'slots' where the subclasses can extend the user * interface. * * @param plot * the plot, which should be changed. */ public DefaultPlotEditor(Plot plot) { this.plotInsets = plot.getInsets(); this.backgroundPaintSample = new PaintSample(plot.getBackgroundPaint()); this.outlineStrokeSample = new StrokeSample(plot.getOutlineStroke()); this.outlinePaintSample = new PaintSample(plot.getOutlinePaint()); // Disabled because makes no sense for us // if (plot instanceof CategoryPlot) { // this.plotOrientation = ((CategoryPlot) plot).getOrientation(); // } else if (plot instanceof XYPlot) { // this.plotOrientation = ((XYPlot) plot).getOrientation(); // } if (plot instanceof CategoryPlot) { CategoryItemRenderer renderer = ((CategoryPlot) plot).getRenderer(); if (renderer instanceof LineAndShapeRenderer) { LineAndShapeRenderer r = (LineAndShapeRenderer) renderer; this.drawLines = BooleanUtilities.valueOf(r.getBaseLinesVisible()); this.drawShapes = BooleanUtilities.valueOf(r.getBaseShapesVisible()); } } else if (plot instanceof XYPlot) { XYItemRenderer renderer = ((XYPlot) plot).getRenderer(); if (renderer instanceof StandardXYItemRenderer) { StandardXYItemRenderer r = (StandardXYItemRenderer) renderer; this.drawLines = BooleanUtilities.valueOf(r.getPlotLines()); this.drawShapes = BooleanUtilities.valueOf(r.getBaseShapesVisible()); } } setLayout(new BorderLayout()); this.availableStrokeSamples = new StrokeSample[4]; this.availableStrokeSamples[0] = new StrokeSample(null); this.availableStrokeSamples[1] = new StrokeSample(new BasicStroke(1.0f)); this.availableStrokeSamples[2] = new StrokeSample(new BasicStroke(2.0f)); this.availableStrokeSamples[3] = new StrokeSample(new BasicStroke(3.0f)); // create a panel for the settings... JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), plot.getPlotType() + localizationResources.getString(":"))); JPanel general = new JPanel(new BorderLayout()); general.setBorder(BorderFactory.createTitledBorder(localizationResources.getString("General"))); JPanel interior = new JPanel(new LCBLayout(7)); interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); interior.add(new JLabel(localizationResources.getString("Outline_stroke"))); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (StrokeSample s : this.availableStrokeSamples) { model.addElement(s.getStroke()); } this.cbOutlineStroke = new JComboBox(model); this.cbOutlineStroke.setSelectedItem(this.outlineStrokeSample.getStroke()); this.cbOutlineStroke.setRenderer(new StrokeComboboxRenderer()); interior.add(this.cbOutlineStroke); interior.add(new JLabel()); interior.add(new JLabel(localizationResources.getString("Outline_Paint"))); JButton button = new JButton(localizationResources.getString("Select...")); button.setActionCommand("OutlinePaint"); button.addActionListener(this); interior.add(this.outlinePaintSample); interior.add(button); interior.add(new JLabel(localizationResources.getString("Background_paint"))); button = new JButton(localizationResources.getString("Select...")); button.setActionCommand("BackgroundPaint"); button.addActionListener(this); interior.add(this.backgroundPaintSample); interior.add(button); // Disabled because makes no sense for us // if (this.plotOrientation != null) { // boolean isVertical = // this.plotOrientation.equals(PlotOrientation.VERTICAL); // int index = isVertical ? ORIENTATION_VERTICAL : // ORIENTATION_HORIZONTAL; // interior.add(new // JLabel(localizationResources.getString("Orientation"))); // this.orientationCombo = new JComboBox(orientationNames); // this.orientationCombo.setSelectedIndex(index); // this.orientationCombo.setActionCommand("Orientation"); // this.orientationCombo.addActionListener(this); // interior.add(this.orientationCombo); // interior.add(new JPanel()); // } if (this.drawLines != null) { interior.add(new JLabel(localizationResources.getString("Draw_lines"))); this.drawLinesCheckBox = new JCheckBox(); this.drawLinesCheckBox.setSelected(this.drawLines.booleanValue()); this.drawLinesCheckBox.setActionCommand("DrawLines"); this.drawLinesCheckBox.addActionListener(this); interior.add(new JPanel()); interior.add(this.drawLinesCheckBox); } if (this.drawShapes != null) { interior.add(new JLabel(localizationResources.getString("Draw_shapes"))); this.drawShapesCheckBox = new JCheckBox(); this.drawShapesCheckBox.setSelected(this.drawShapes.booleanValue()); this.drawShapesCheckBox.setActionCommand("DrawShapes"); this.drawShapesCheckBox.addActionListener(this); interior.add(new JPanel()); interior.add(this.drawShapesCheckBox); } general.add(interior, BorderLayout.NORTH); JPanel appearance = new JPanel(new BorderLayout()); appearance.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); appearance.add(general, BorderLayout.NORTH); JTabbedPane tabs = new JTabbedPane(); tabs.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); Axis domainAxis = null; if (plot instanceof CategoryPlot) { domainAxis = ((CategoryPlot) plot).getDomainAxis(); } else if (plot instanceof XYPlot) { domainAxis = ((XYPlot) plot).getDomainAxis(); } this.domainAxisPropertyPanel = DefaultAxisEditor.getInstance(domainAxis); if (this.domainAxisPropertyPanel != null) { this.domainAxisPropertyPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); tabs.add(localizationResources.getString("Domain_Axis"), this.domainAxisPropertyPanel); } Axis rangeAxis = null; if (plot instanceof CategoryPlot) { rangeAxis = ((CategoryPlot) plot).getRangeAxis(); } else if (plot instanceof XYPlot) { rangeAxis = ((XYPlot) plot).getRangeAxis(); } this.rangeAxisPropertyPanel = DefaultAxisEditor.getInstance(rangeAxis); if (this.rangeAxisPropertyPanel != null) { this.rangeAxisPropertyPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); tabs.add(localizationResources.getString("Range_Axis"), this.rangeAxisPropertyPanel); } tabs.add(localizationResources.getString("Appearance"), appearance); panel.add(tabs); add(panel); }
From source file:ToolBarDemo2.java
protected void addButtons(JToolBar toolBar) { JButton button = null; //first button button = makeNavigationButton("Back24", PREVIOUS, "Back to previous something-or-other", "Previous"); toolBar.add(button);/*from ww w . j ava2s . c o m*/ //second button button = makeNavigationButton("Up24", UP, "Up to something-or-other", "Up"); toolBar.add(button); //third button button = makeNavigationButton("Forward24", NEXT, "Forward to something-or-other", "Next"); toolBar.add(button); //separator toolBar.addSeparator(); //fourth button button = new JButton("Another button"); button.setActionCommand(SOMETHING_ELSE); button.setToolTipText("Something else"); button.addActionListener(this); toolBar.add(button); //fifth component is NOT a button! JTextField textField = new JTextField("A text field"); textField.setColumns(10); textField.addActionListener(this); textField.setActionCommand(TEXT_ENTERED); toolBar.add(textField); }
From source file:edu.harvard.mcz.imagecapture.SpecimenPartAttributeDialog.java
private void init() { thisDialog = this; setBounds(100, 100, 820, 335);/*from ww w . j a v a 2 s . com*/ getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); JPanel panel = new JPanel(); panel.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); { JLabel lblAttributeType = new JLabel("Attribute Type"); panel.add(lblAttributeType, "2, 2, right, default"); } { comboBoxType = new JComboBox(); comboBoxType.setModel(new DefaultComboBoxModel( new String[] { "caste", "scientific name", "sex", "life stage", "part association" })); comboBoxType.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String item = comboBoxType.getSelectedItem().toString(); if (item != null) { comboBoxValue.setEditable(false); if (item.equals("scientific name")) { comboBoxValue.setEditable(true); } if (item.equals("sex")) { comboBoxValue.setModel(new DefaultComboBoxModel(Sex.getSexValues())); } if (item.equals("life stage")) { comboBoxValue.setModel(new DefaultComboBoxModel(LifeStage.getLifeStageValues())); } if (item.equals("caste")) { comboBoxValue.setModel(new DefaultComboBoxModel(Caste.getCasteValues())); } if (item.equals("part association")) { comboBoxValue .setModel(new DefaultComboBoxModel(PartAssociation.getPartAssociationValues())); } } } }); panel.add(comboBoxType, "4, 2, fill, default"); } { JLabel lblValue = new JLabel("Value"); panel.add(lblValue, "2, 4, right, default"); } { comboBoxValue = new JComboBox(); comboBoxValue.setModel(new DefaultComboBoxModel(Caste.getCasteValues())); panel.add(comboBoxValue, "4, 4, fill, default"); } { JLabel lblUnits = new JLabel("Units"); panel.add(lblUnits, "2, 6, right, default"); } { textFieldUnits = new JTextField(); panel.add(textFieldUnits, "4, 6, fill, default"); textFieldUnits.setColumns(10); } { JLabel lblRemarks = new JLabel("Remarks"); panel.add(lblRemarks, "2, 8, right, default"); } contentPanel.setLayout(new BorderLayout(0, 0)); contentPanel.add(panel, BorderLayout.WEST); { textFieldRemarks = new JTextField(); panel.add(textFieldRemarks, "4, 8, fill, default"); textFieldRemarks.setColumns(10); } { JButton btnAdd = new JButton("Add"); btnAdd.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SpecimenPartAttribute newAttribs = new SpecimenPartAttribute(); newAttribs.setAttributeType(comboBoxType.getSelectedItem().toString()); newAttribs.setAttributeValue(comboBoxValue.getSelectedItem().toString()); newAttribs.setAttributeUnits(textFieldUnits.getText()); newAttribs.setAttributeRemark(textFieldRemarks.getText()); newAttribs.setSpecimenPartId(parentPart); newAttribs.setAttributeDeterminer(Singleton.getSingletonInstance().getUserFullName()); parentPart.getAttributeCollection().add(newAttribs); SpecimenPartAttributeLifeCycle sls = new SpecimenPartAttributeLifeCycle(); try { sls.attachDirty(newAttribs); } catch (SaveFailedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ((AbstractTableModel) table.getModel()).fireTableDataChanged(); } }); panel.add(btnAdd, "4, 10"); } try { JLabel lblNewLabel = new JLabel(parentPart.getSpecimenId().getBarcode() + ":" + parentPart.getPartName() + " " + parentPart.getPreserveMethod() + " (" + parentPart.getLotCount() + ") Right click on table to edit attributes."); contentPanel.add(lblNewLabel, BorderLayout.NORTH); } catch (Exception e) { JLabel lblNewLabel = new JLabel("No Specimen"); contentPanel.add(lblNewLabel, BorderLayout.NORTH); } JComboBox comboBox = new JComboBox(); comboBox.addItem("caste"); JComboBox comboBox1 = new JComboBox(); for (int i = 0; i < Caste.getCasteValues().length; i++) { comboBox1.addItem(Caste.getCasteValues()[i]); } JScrollPane scrollPane = new JScrollPane(); table = new JTable(new SpecimenPartsAttrTableModel( (Collection<SpecimenPartAttribute>) parentPart.getAttributeCollection())); //table.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(comboBox)); table.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { clickedOnRow = ((JTable) e.getComponent()).getSelectedRow(); popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { clickedOnRow = ((JTable) e.getComponent()).getSelectedRow(); popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } }); popupMenu = new JPopupMenu(); JMenuItem mntmCloneRow = new JMenuItem("Edit Row"); mntmCloneRow.setMnemonic(KeyEvent.VK_E); mntmCloneRow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { // Launch a dialog to edit the selected row. SpecimenPartAttribEditDialog popup = new SpecimenPartAttribEditDialog( ((SpecimenPartsAttrTableModel) table.getModel()).getRowObject(clickedOnRow)); popup.setVisible(true); } catch (Exception ex) { log.error(ex.getMessage()); JOptionPane.showMessageDialog(thisDialog, "Failed to edit a part attribute row. " + ex.getMessage()); } } }); popupMenu.add(mntmCloneRow); JMenuItem mntmDeleteRow = new JMenuItem("Delete Row"); mntmDeleteRow.setMnemonic(KeyEvent.VK_D); mntmDeleteRow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { if (clickedOnRow >= 0) { ((SpecimenPartsAttrTableModel) table.getModel()).deleteRow(clickedOnRow); } } catch (Exception ex) { log.error(ex.getMessage()); JOptionPane.showMessageDialog(thisDialog, "Failed to delete a part attribute row. " + ex.getMessage()); } } }); popupMenu.add(mntmDeleteRow); // TODO: Enable controlled value editing of selected row. // table.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(comboBox1)); scrollPane.setViewportView(table); contentPanel.add(scrollPane, BorderLayout.EAST); { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { okButton.grabFocus(); thisDialog.setVisible(false); } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { thisDialog.setVisible(false); } }); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } } }
From source file:com.ibm.issw.odc.gui.BPMArgumentsPanel.java
/** * Create a panel containing the add and delete buttons. * * @return a GUI panel containing the buttons *//*from ww w.j a v a 2 s .c om*/ private JPanel makeButtonPanel() { JButton showDetail = new JButton(JMeterUtils.getResString("detail")); // $NON-NLS-1$ showDetail.setActionCommand(DETAIL); showDetail.setEnabled(true); add = new JButton(JMeterUtils.getResString("add")); // $NON-NLS-1$ add.setActionCommand(ADD); add.setEnabled(true); /** A button for adding new arguments to the table from the clipboard. */ JButton addFromClipboard = new JButton(JMeterUtils.getResString("add_from_clipboard")); // $NON-NLS-1$ addFromClipboard.setActionCommand(ADD_FROM_CLIPBOARD); addFromClipboard.setEnabled(true); delete = new JButton(JMeterUtils.getResString("delete")); // $NON-NLS-1$ delete.setActionCommand(DELETE); if (enableUpDown) { up = new JButton(JMeterUtils.getResString("up")); // $NON-NLS-1$ up.setActionCommand(UP); down = new JButton(JMeterUtils.getResString("down")); // $NON-NLS-1$ down.setActionCommand(DOWN); } checkDeleteStatus(); JPanel buttonPanel = new JPanel(); buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); if (this.background != null) { buttonPanel.setBackground(this.background); } showDetail.addActionListener(this); add.addActionListener(this); addFromClipboard.addActionListener(this); delete.addActionListener(this); buttonPanel.add(showDetail); buttonPanel.add(add); buttonPanel.add(addFromClipboard); buttonPanel.add(delete); if (enableUpDown) { up.addActionListener(this); down.addActionListener(this); buttonPanel.add(up); buttonPanel.add(down); } return buttonPanel; }
From source file:org.gumtree.vis.awt.time.TimePlotChartEditor.java
private JPanel createCurvesPanel() { JPanel wrap = new JPanel(new BorderLayout()); JPanel curves = new JPanel(new BorderLayout()); curves.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // JPanel general = new JPanel(new BorderLayout()); // general.setBorder(BorderFactory.createTitledBorder( // BorderFactory.createEtchedBorder(), "General")); ////from w w w .j av a 2s .c o m // JPanel inner = new JPanel(new LCBLayout(6)); // inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); // // inner.add(new JLabel("Show Marker")); // showMarker = new JCheckBox(); // showMarker.setActionCommand(SHOW_MARKER_COMMAND); // showMarker.addActionListener(this); // inner.add(showMarker); // inner.add(new JLabel()); // inner.add(new JLabel("Show Error")); // showError = new JCheckBox(); // showError.setActionCommand(SHOW_ERROR_COMMAND); // showError.addActionListener(this); // inner.add(showError); // inner.add(new JLabel()); // // general.add(inner, BorderLayout.NORTH); // curves.add(general, BorderLayout.NORTH); JPanel individual = new JPanel(new BorderLayout()); individual.setBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Individual Curve")); JPanel interior = new JPanel(new LCBLayout(7)); interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); int numberOfDataset = chart.getXYPlot().getDatasetCount(); currentDataset = null; currentSeriesIndex = -1; List<String> seriesNames = new ArrayList<String>(); for (int i = 0; i < numberOfDataset; i++) { XYDataset dataset = chart.getXYPlot().getDataset(i); if (dataset != null && dataset instanceof ITimeSeriesSet) { int numberOfSeries = dataset.getSeriesCount(); for (int j = 0; j < numberOfSeries; j++) { String seriesName = (String) dataset.getSeriesKey(j); seriesNames.add(seriesName); if (seriesName.equals(currentSeriesKey)) { currentDataset = (IDataset) dataset; currentSeriesIndex = j; } } } } if ((currentDataset == null || currentSeriesIndex < 0) && seriesNames.size() > 0) { for (int i = 0; i < numberOfDataset; i++) { XYDataset dataset = chart.getXYPlot().getDataset(i); if (dataset != null && dataset instanceof ITimeSeriesSet && dataset.getSeriesCount() > 0) { currentDataset = (IDataset) dataset; currentSeriesIndex = 0; currentSeriesKey = (String) dataset.getSeriesKey(currentSeriesIndex); break; } } } //Select curve combo this.seriesCombo = new JComboBox(seriesNames.toArray()); seriesCombo.setActionCommand(CHANGE_CURVE_COMMAND); seriesCombo.addActionListener(this); interior.add(new JLabel("Select Curve")); interior.add(seriesCombo); interior.add(new JLabel("")); interior.add(new JLabel("Curve Stroke")); curveStrokeSample = new StrokeSample(new BasicStroke()); curveStrokeSample.setEnabled(false); interior.add(curveStrokeSample); // JButton button = new JButton(localizationResources.getString("Edit...")); Float[] strokes = new Float[] { 0f, 0.2f, 0.5f, 1f, 1.5f, 2f, 3f }; strokeCombo = new JComboBox(strokes); strokeCombo.setActionCommand(CURVE_STROCK_COMMAND); strokeCombo.addActionListener(this); interior.add(strokeCombo); interior.add(new JLabel("Curve Colour")); curveColorPaint = new PaintSample(chart.getBackgroundPaint()); interior.add(curveColorPaint); JButton button = new JButton(localizationResources.getString("Edit...")); button.setActionCommand(CURVE_COLOR_COMMAND); button.addActionListener(this); interior.add(button); interior.add(new JLabel("Marker Visible")); showMarker = new JCheckBox(); showMarker.setActionCommand(SHOW_MARKER_COMMAND); showMarker.addActionListener(this); interior.add(showMarker); interior.add(new JLabel()); interior.add(new JLabel("Marker Shape")); shapeLabel = new JLabel(); interior.add(shapeLabel); Integer[] shapeIndex = new Integer[MarkerShape.size]; for (int i = 0; i < shapeIndex.length; i++) { shapeIndex[i] = i; } shapeCombo = new JComboBox(shapeIndex); comboRender = new ImageComboRender(); comboRender.setShapes(StaticValues.LOCAL_SHAPE_SERIES); shapeCombo.setRenderer(comboRender); shapeCombo.setMaximumRowCount(7); shapeCombo.setActionCommand(MARKER_SHAPE_COMMAND); shapeCombo.addActionListener(this); interior.add(shapeCombo); interior.add(new JLabel("Marker Filled")); markerFilled = new JCheckBox(); markerFilled.setActionCommand(MARKER_FILLED_COMMAND); markerFilled.addActionListener(this); interior.add(markerFilled); interior.add(new JLabel()); interior.add(new JLabel("Curve Visable")); curveVisable = new JCheckBox(); curveVisable.setActionCommand(CURVE_VISIBLE_COMMAND); curveVisable.addActionListener(this); interior.add(curveVisable); interior.add(new JLabel()); individual.add(interior, BorderLayout.NORTH); curves.add(individual, BorderLayout.NORTH); curves.setName("Curves"); wrap.setName("Curves"); wrap.add(curves, BorderLayout.NORTH); return wrap; }
From source file:net.sf.xmm.moviemanager.gui.DialogIMDbMultiAdd.java
JButton createChooseBetweenImdbAndLocalDatabaseButton() { /*This button choses between IMDB and local movie database*/ final JButton chooseBetweenImdbAndLocalDatabase = new JButton( Localizer.get("DialogIMDbMultiAdd.button.add-to-existing-movie.text")); //$NON-NLS-1$ chooseBetweenImdbAndLocalDatabase//from w ww .jav a 2 s . c om .setToolTipText(Localizer.get("DialogIMDbMultiAdd.button.add-to-existing-movie.tooltip")); //$NON-NLS-1$ chooseBetweenImdbAndLocalDatabase.setActionCommand("GetIMDBInfo - chooseBetweenImdbAndLocalDatabase"); //$NON-NLS-1$ chooseBetweenImdbAndLocalDatabase.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { log.debug("ActionPerformed: " + event.getActionCommand()); //$NON-NLS-1$ if (addInfoToExistingMovie) { getPanelMoviesList().setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Localizer.get("DialogIMDB.panel-movie-list.title")), //$NON-NLS-1$ BorderFactory.createEmptyBorder(5, 5, 5, 5))); chooseBetweenImdbAndLocalDatabase .setText(Localizer.get("DialogIMDbMultiAdd.button.add-to-existing-movie.text")); //$NON-NLS-1$ chooseBetweenImdbAndLocalDatabase.setToolTipText( Localizer.get("DialogIMDbMultiAdd.button.add-to-existing-movie.tooltip")); //$NON-NLS-1$ addInfoToExistingMovie = false; executeSearchMultipleMovies(); } else { executeEditExistingMovie(""); //$NON-NLS-1$ chooseBetweenImdbAndLocalDatabase .setText(Localizer.get("DialogIMDbMultiAdd.button.search-on-IMDb.text")); //$NON-NLS-1$ chooseBetweenImdbAndLocalDatabase .setToolTipText(Localizer.get("DialogIMDbMultiAdd.button.search-on-IMDb.tooltip")); //$NON-NLS-1$ addInfoToExistingMovie = true; getPanelMoviesList().setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Localizer.get("DialogIMDB.panel-your-movie-list.title")), //$NON-NLS-1$ BorderFactory.createEmptyBorder(5, 5, 5, 5))); } } }); return chooseBetweenImdbAndLocalDatabase; }
From source file:org.simbrain.plot.projection.ProjectionGui.java
/** * Construct the Projection GUI.//from w ww .j a va 2 s .com */ public ProjectionGui(final GenericFrame frame, final ProjectionComponent component) { super(frame, component); setPreferredSize(new Dimension(500, 400)); actionManager = new PlotActionManager(this); setLayout(new BorderLayout()); // Generate the graph chart = ChartFactory.createScatterPlot("High Dimensional Projection", "Projection X", "Projection Y", getWorkspaceComponent().getProjectionModel().getDataset(), PlotOrientation.VERTICAL, false, true, false); // chart.getXYPlot().getDomainAxis().setRange(-100, 100); // chart.getXYPlot().getRangeAxis().setRange(-100, 100); chart.getXYPlot().setBackgroundPaint(Color.white); chart.getXYPlot().setDomainGridlinePaint(Color.gray); chart.getXYPlot().setRangeGridlinePaint(Color.gray); chart.getXYPlot().getDomainAxis().setAutoRange(true); chart.getXYPlot().getRangeAxis().setAutoRange(true); panel = new ChartPanel(chart); // Custom render points as dots (not squares) and use custom tooltips // that show high-d point CustomRenderer renderer = new CustomRenderer(); chart.getXYPlot().setRenderer(renderer); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShape(0, new Ellipse2D.Double(-5, -5, 5, 5)); CustomToolTipGenerator generator = new CustomToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, generator); // Toolbar openBtn.setToolTipText("Open high-dimensional data"); saveBtn.setToolTipText("Save data"); projectionList.setMaximumSize(new java.awt.Dimension(200, 100)); iterateBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getWorkspaceComponent().getProjector().iterate(); update(); } }); clearBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getWorkspaceComponent().getWorkspace().stop(); Executors.newSingleThreadExecutor().execute(new Runnable() { @Override public void run() { getWorkspaceComponent().clearData(); } }); } }); playBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (getWorkspaceComponent().getProjectionModel().isRunning()) { playBtn.setIcon(ResourceManager.getImageIcon("Stop.png")); playBtn.setToolTipText("Stop iterating projection algorithm"); getWorkspaceComponent().getProjectionModel().setRunning(false); Executors.newSingleThreadExecutor().execute(new ProjectionUpdater(getWorkspaceComponent())); } else { playBtn.setIcon(ResourceManager.getImageIcon("Play.png")); playBtn.setToolTipText("Start iterating projection algorithm"); getWorkspaceComponent().getProjectionModel().setRunning(true); } } }); prefsBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO (Still working out overall dialog structure). } }); randomBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getWorkspaceComponent().getProjector().randomize(100); } }); theToolBar.add(projectionList); playBtn.setToolTipText("Iterate projection algorithm"); theToolBar.add(playBtn); iterateBtn.setToolTipText("Step projection algorithm"); theToolBar.add(iterateBtn); clearBtn.setToolTipText("Clear current data"); theToolBar.add(clearBtn); randomBtn.setToolTipText("Randomize datapoints"); theToolBar.add(randomBtn); theToolBar.addSeparator(); warningLabel.setPreferredSize(new Dimension(16, 16)); warningLabel.setToolTipText("This method works best with more " + "datapoints already added"); theToolBar.add(warningLabel); String stepSizeToolTip = "Scales the amount points are moved on each iteration"; JLabel stepSizeLabel = new JLabel("Step Size"); stepSizeLabel.setToolTipText(stepSizeToolTip); sammonStepSizePanel.add(stepSizeLabel); try { sammonStepSize = new JTextField("" + SimbrainPreferences.getDouble("projectorSammonEpsilon")); } catch (PropertyNotFoundException e1) { e1.printStackTrace(); } sammonStepSize.setColumns(3); sammonStepSize.setToolTipText(stepSizeToolTip); sammonStepSizePanel.add(sammonStepSize); theToolBar.add(sammonStepSizePanel); adjustDimension1.setToolTipText("Dimension 1"); adjustDimension2.setToolTipText("Dimension 2"); theToolBar.add(adjustDimension1); theToolBar.add(adjustDimension2); // Help button JButton helpButton = new JButton(); helpButton.setAction(helpAction); // Add/Remove dimension buttons JButton addButton = new JButton("Add Dimension"); addButton.setActionCommand("Add"); addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getWorkspaceComponent().getProjectionModel().addSource(); } }); JButton deleteButton = new JButton("Remove Dimension"); deleteButton.setActionCommand("Delete"); deleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getWorkspaceComponent().getProjectionModel().removeSource(); } }); // Button Panel JPanel buttonPanel = new JPanel(); buttonPanel.add(helpButton); buttonPanel.add(addButton); buttonPanel.add(deleteButton); // Setup Menu Bar createAttachMenuBar(); // Status Bar statusBar.add(pointsLabel); statusBar.add(dimsLabel); errorBar.add(errorLabel); // Bottom panel bottomPanel.add("North", buttonPanel); JPanel southPanel = new JPanel(); southPanel.add(errorBar); southPanel.add(statusBar); bottomPanel.add("South", southPanel); // Put all panels together add("North", theToolBar); add("Center", panel); add("South", bottomPanel); // Other initialization initializeComboBoxes(); addListeners(); updateToolBar(); update(); }
From source file:net.mariottini.swing.JFontChooser.java
/** * Construct a font chooser with the specified fonts, optionally showing a sample to the user. The * sample text is a default text, you can change it by calling <code>setSampleText</code>. * //w ww . j a va2s. co m * @param fontNames * the font family names to show to the user. * @param showSample * true to show a sample of the selected font to the user. * @see #setSampleText */ public JFontChooser(String[] fontNames, boolean showSample) { setLayout(new BorderLayout()); JPanel centerPanel = new JPanel(new BorderLayout()); // Uncomment one of the two lines below to use a standard layout manager // instead of my MeshLayout manager. The result is ugly. // JPanel listsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));/* // JPanel listsPanel = new JPanel(new GridLayout(0, 3));/* net.mariottini.layout.MeshLayout mesh = new net.mariottini.layout.MeshLayout(0, 3, 0); mesh.setExpandColumn(0); JPanel listsPanel = new JPanel(mesh);// */ JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); panel.add(new JLabel("Family name:"), BorderLayout.NORTH); fontList = new JList<>(fontNames); fontList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); fontList.setVisibleRowCount(7); fontList.setSelectedIndex(0); panel.add(new JScrollPane(fontList), BorderLayout.CENTER); listsPanel.add(panel); panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createEmptyBorder(8, 0, 8, 8)); panel.add(new JLabel("Style:"), BorderLayout.NORTH); styleList = new JList<>(STYLE_NAMES); styleList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); styleList.setVisibleRowCount(7); styleList.setSelectedIndex(0); panel.add(new JScrollPane(styleList), BorderLayout.CENTER); listsPanel.add(panel); panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createEmptyBorder(8, 0, 8, 8)); panel.add(new JLabel("Size:"), BorderLayout.NORTH); JPanel sizePanel = new JPanel(new BorderLayout()); sizeText = new JTextField(String.valueOf(SIZES[0]), 4); sizePanel.add(sizeText, BorderLayout.NORTH); sizeList = new JList<>(ArrayUtils.toObject(SIZES)); sizeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); sizeList.setVisibleRowCount(6); sizePanel.add(new JScrollPane(sizeList), BorderLayout.CENTER); panel.add(sizePanel, BorderLayout.CENTER); listsPanel.add(panel); centerPanel.add(listsPanel, BorderLayout.NORTH); samplePanel = new JPanel(new BorderLayout()); samplePanel.setBorder(BorderFactory.createEmptyBorder(0, 8, 4, 8)); samplePanel.add(new JLabel("Sample:"), BorderLayout.NORTH); sampleLabel = new JLabel(DEFAULT_SAMPLE_TEXT, JLabel.CENTER); sampleLabel.setMinimumSize(new Dimension(64, 48)); sampleLabel.setOpaque(true); sampleLabel.setBackground(sizeList.getBackground()); sampleLabel.setBorder(sizeText.getBorder()); samplePanel.add(sampleLabel, BorderLayout.CENTER); samplePanel.setVisible(showSample); centerPanel.add(samplePanel, BorderLayout.CENTER); add(centerPanel, BorderLayout.CENTER); accessoryPanel = new JPanel(new BorderLayout()); accessoryPanel.setBorder(BorderFactory.createEmptyBorder(8, 0, 4, 8)); accessoryComponent = new JLabel("Accessory"); accessoryComponent.setOpaque(true); accessoryComponent.setBackground(sizeList.getBackground()); accessoryPanel.add(accessoryComponent, BorderLayout.CENTER); accessoryPanel.setVisible(false); add(accessoryPanel, BorderLayout.EAST); JPanel southPanel = new JPanel(new BorderLayout()); southPanel.add(new JLabel(), BorderLayout.CENTER); JPanel buttonsPanel = new JPanel(); ActionListener actionListener = new ButtonActionListener(); JButton button = new JButton("OK"); button.addActionListener(actionListener); button.setActionCommand(APPROVE_SELECTION); buttonsPanel.add(button); button = new JButton("Cancel"); button.addActionListener(actionListener); button.setActionCommand(CANCEL_SELECTION); buttonsPanel.add(button); southPanel.add(buttonsPanel, BorderLayout.EAST); add(southPanel, BorderLayout.SOUTH); // * Fix list size (optional) Dimension d = fontList.getPreferredSize(); d.width += 6; fontList.setPreferredSize(d); d = styleList.getPreferredSize(); d.width += 6; styleList.setPreferredSize(d); d = sizeList.getPreferredSize(); d.width += 6; sizeList.setPreferredSize(d); // */ // Fix sample size Dimension pref = sampleLabel.getPreferredSize(); Dimension min = sampleLabel.getMinimumSize(); pref.width += 16; pref.height += 12; if (pref.width < min.width) { pref.width = min.width; } if (pref.height < min.height) { pref.height = min.height; } sampleLabel.setPreferredSize(pref); // set listener SampleListener pl = new SampleListener(); fontList.addListSelectionListener(pl); styleList.addListSelectionListener(pl); sizeList.addListSelectionListener(pl); sizeList.addListSelectionListener(new SizeListListener()); sizeText.getDocument().addDocumentListener(new SizeTextListener()); sizeText.addFocusListener(new SizeTextFocusListener()); sizeList.setSelectedIndex(5); }
From source file:edu.harvard.mcz.imagecapture.VerbatimCaptureDialog.java
protected void init() { setDefaultCloseOperation(DISPOSE_ON_CLOSE); setTitle("Transcribe Verbatim Data"); setMinimumSize(new Dimension(1020, 640)); setBounds(100, 100, 1020, 640);// w w w .ja v a2s. c o m getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(new BorderLayout(0, 0)); { JPanel panel = new JPanel(); contentPanel.add(panel, BorderLayout.NORTH); panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); JLabel lblVerbatimDataFor = new JLabel("Verbatim Data for:"); panel.add(lblVerbatimDataFor); lblBarcode = new JLabel("Barcode"); panel.add(lblBarcode); lblCurrentid = new JLabel("CurrentID"); panel.add(lblCurrentid); } { JPanel panel = new JPanel(); contentPanel.add(panel, BorderLayout.WEST); GridBagLayout gbl_panel = new GridBagLayout(); gbl_panel.columnWidths = new int[] { 0, 0, 0, 0 }; gbl_panel.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; gbl_panel.columnWeights = new double[] { 0.0, 1.0, 1.0, Double.MIN_VALUE }; gbl_panel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE }; panel.setLayout(gbl_panel); JLabel lblNewLabel = new JLabel("Locality"); GridBagConstraints gbc_lblNewLabel = new GridBagConstraints(); gbc_lblNewLabel.anchor = GridBagConstraints.NORTHEAST; gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5); gbc_lblNewLabel.gridx = 0; gbc_lblNewLabel.gridy = 0; panel.add(lblNewLabel, gbc_lblNewLabel); textFieldVerbLocality = new JTextArea(); textFieldVerbLocality.setRows(3); GridBagConstraints gbc_textFieldVerbLocality = new GridBagConstraints(); gbc_textFieldVerbLocality.gridheight = 2; gbc_textFieldVerbLocality.gridwidth = 2; gbc_textFieldVerbLocality.insets = new Insets(0, 0, 5, 5); gbc_textFieldVerbLocality.fill = GridBagConstraints.BOTH; gbc_textFieldVerbLocality.gridx = 1; gbc_textFieldVerbLocality.gridy = 0; panel.add(textFieldVerbLocality, gbc_textFieldVerbLocality); textFieldVerbLocality.setColumns(10); JLabel lblVerbatimDate = new JLabel("Date"); GridBagConstraints gbc_lblVerbatimDate = new GridBagConstraints(); gbc_lblVerbatimDate.anchor = GridBagConstraints.EAST; gbc_lblVerbatimDate.insets = new Insets(0, 0, 5, 5); gbc_lblVerbatimDate.gridx = 0; gbc_lblVerbatimDate.gridy = 2; panel.add(lblVerbatimDate, gbc_lblVerbatimDate); textFieldVerbDate = new JTextField(); GridBagConstraints gbc_textFieldVerbDate = new GridBagConstraints(); gbc_textFieldVerbDate.insets = new Insets(0, 0, 5, 5); gbc_textFieldVerbDate.gridwidth = 2; gbc_textFieldVerbDate.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldVerbDate.gridx = 1; gbc_textFieldVerbDate.gridy = 2; panel.add(textFieldVerbDate, gbc_textFieldVerbDate); textFieldVerbDate.setColumns(10); JLabel lblCollector = new JLabel("Collector"); GridBagConstraints gbc_lblCollector = new GridBagConstraints(); gbc_lblCollector.anchor = GridBagConstraints.EAST; gbc_lblCollector.insets = new Insets(0, 0, 5, 5); gbc_lblCollector.gridx = 0; gbc_lblCollector.gridy = 3; panel.add(lblCollector, gbc_lblCollector); textFieldVerbCollector = new JTextField(); GridBagConstraints gbc_textFieldVerbCollector = new GridBagConstraints(); gbc_textFieldVerbCollector.insets = new Insets(0, 0, 5, 5); gbc_textFieldVerbCollector.gridwidth = 2; gbc_textFieldVerbCollector.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldVerbCollector.gridx = 1; gbc_textFieldVerbCollector.gridy = 3; panel.add(textFieldVerbCollector, gbc_textFieldVerbCollector); textFieldVerbCollector.setColumns(10); JLabel lblNewLabel_1 = new JLabel("Collection"); GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints(); gbc_lblNewLabel_1.anchor = GridBagConstraints.EAST; gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5); gbc_lblNewLabel_1.gridx = 0; gbc_lblNewLabel_1.gridy = 4; panel.add(lblNewLabel_1, gbc_lblNewLabel_1); textFieldVerbCollection = new JTextField(); GridBagConstraints gbc_textFieldVerbCollection = new GridBagConstraints(); gbc_textFieldVerbCollection.insets = new Insets(0, 0, 5, 5); gbc_textFieldVerbCollection.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldVerbCollection.gridx = 2; gbc_textFieldVerbCollection.gridy = 4; panel.add(textFieldVerbCollection, gbc_textFieldVerbCollection); textFieldVerbCollection.setColumns(10); JLabel lblNumbers = new JLabel("Numbers"); GridBagConstraints gbc_lblNumbers = new GridBagConstraints(); gbc_lblNumbers.anchor = GridBagConstraints.EAST; gbc_lblNumbers.insets = new Insets(0, 0, 5, 5); gbc_lblNumbers.gridx = 0; gbc_lblNumbers.gridy = 5; panel.add(lblNumbers, gbc_lblNumbers); textFieldVerbNumbers = new JTextField(); GridBagConstraints gbc_textFieldVerbNumbers = new GridBagConstraints(); gbc_textFieldVerbNumbers.insets = new Insets(0, 0, 5, 5); gbc_textFieldVerbNumbers.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldVerbNumbers.gridx = 2; gbc_textFieldVerbNumbers.gridy = 5; panel.add(textFieldVerbNumbers, gbc_textFieldVerbNumbers); textFieldVerbNumbers.setColumns(10); JLabel lblNewLabel_2 = new JLabel("Other Text"); GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints(); gbc_lblNewLabel_2.anchor = GridBagConstraints.EAST; gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 5); gbc_lblNewLabel_2.gridx = 0; gbc_lblNewLabel_2.gridy = 6; panel.add(lblNewLabel_2, gbc_lblNewLabel_2); textFieldVerbUnclassifiedText = new JTextArea(); textFieldVerbUnclassifiedText.setRows(3); GridBagConstraints gbc_textFieldVerbUnclassifiedText = new GridBagConstraints(); gbc_textFieldVerbUnclassifiedText.gridheight = 2; gbc_textFieldVerbUnclassifiedText.insets = new Insets(0, 0, 5, 5); gbc_textFieldVerbUnclassifiedText.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldVerbUnclassifiedText.gridx = 2; gbc_textFieldVerbUnclassifiedText.gridy = 6; panel.add(textFieldVerbUnclassifiedText, gbc_textFieldVerbUnclassifiedText); textFieldVerbUnclassifiedText.setColumns(10); JLabel lblQuestions = new JLabel("Questions"); GridBagConstraints gbc_lblQuestions = new GridBagConstraints(); gbc_lblQuestions.anchor = GridBagConstraints.EAST; gbc_lblQuestions.insets = new Insets(0, 0, 5, 5); gbc_lblQuestions.gridx = 0; gbc_lblQuestions.gridy = 8; panel.add(lblQuestions, gbc_lblQuestions); textFieldQuestions = new JTextField(); GridBagConstraints gbc_textFieldQuestions = new GridBagConstraints(); gbc_textFieldQuestions.insets = new Insets(0, 0, 5, 5); gbc_textFieldQuestions.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldQuestions.gridx = 2; gbc_textFieldQuestions.gridy = 8; panel.add(textFieldQuestions, gbc_textFieldQuestions); textFieldQuestions.setColumns(30); JLabel lblWorkflowStatus = new JLabel("Workflow Status"); GridBagConstraints gbc_lblWorkflowStatus = new GridBagConstraints(); gbc_lblWorkflowStatus.anchor = GridBagConstraints.EAST; gbc_lblWorkflowStatus.insets = new Insets(0, 0, 5, 5); gbc_lblWorkflowStatus.gridx = 0; gbc_lblWorkflowStatus.gridy = 9; panel.add(lblWorkflowStatus, gbc_lblWorkflowStatus); comboBoxWorkflowStatus = new JComboBox<String>(WorkFlowStatus.getVerbatimWorkFlowStatusValues()); GridBagConstraints gbc_comboBoxWorkflowStatus = new GridBagConstraints(); gbc_comboBoxWorkflowStatus.insets = new Insets(0, 0, 5, 0); gbc_comboBoxWorkflowStatus.gridwidth = 2; gbc_comboBoxWorkflowStatus.fill = GridBagConstraints.HORIZONTAL; gbc_comboBoxWorkflowStatus.gridx = 2; gbc_comboBoxWorkflowStatus.gridy = 9; panel.add(comboBoxWorkflowStatus, gbc_comboBoxWorkflowStatus); JPanel panel_1 = new JPanel(); GridBagConstraints gbc_panel_1 = new GridBagConstraints(); gbc_panel_1.gridwidth = 2; gbc_panel_1.insets = new Insets(0, 0, 0, 5); gbc_panel_1.fill = GridBagConstraints.BOTH; gbc_panel_1.gridx = 2; gbc_panel_1.gridy = 11; panel.add(panel_1, gbc_panel_1); GridBagLayout gbl_panel_1 = new GridBagLayout(); gbl_panel_1.columnWidths = new int[] { 150, 143, 0 }; gbl_panel_1.rowHeights = new int[] { 25, 0, 0, 0, 0 }; gbl_panel_1.columnWeights = new double[] { 0.0, 0.0, 0.0 }; gbl_panel_1.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; panel_1.setLayout(gbl_panel_1); JButton btnPartiallyIllegible = new JButton("Partially Illegible"); btnPartiallyIllegible.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { appendToQuestions(Verbatim.PARTLY_ILLEGIBLE); } }); GridBagConstraints gbc_btnPartiallyIllegible = new GridBagConstraints(); gbc_btnPartiallyIllegible.fill = GridBagConstraints.HORIZONTAL; gbc_btnPartiallyIllegible.anchor = GridBagConstraints.NORTH; gbc_btnPartiallyIllegible.insets = new Insets(0, 0, 5, 5); gbc_btnPartiallyIllegible.gridx = 0; gbc_btnPartiallyIllegible.gridy = 0; panel_1.add(btnPartiallyIllegible, gbc_btnPartiallyIllegible); JButton btnNewButton = new JButton("No Locality Data"); btnNewButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { textFieldVerbLocality.setText(Verbatim.NO_LOCALITY_DATA); } }); GridBagConstraints gbc_btnNewButton = new GridBagConstraints(); gbc_btnNewButton.anchor = GridBagConstraints.NORTHWEST; gbc_btnNewButton.insets = new Insets(0, 0, 5, 5); gbc_btnNewButton.gridx = 1; gbc_btnNewButton.gridy = 0; panel_1.add(btnNewButton, gbc_btnNewButton); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); JButton btnNewButton_1 = new JButton("Entirely Illegible"); btnNewButton_1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { appendToQuestions(Verbatim.ENTIRELY_ILLEGIBLE); } }); GridBagConstraints gbc_btnNewButton_1 = new GridBagConstraints(); gbc_btnNewButton_1.fill = GridBagConstraints.HORIZONTAL; gbc_btnNewButton_1.anchor = GridBagConstraints.NORTH; gbc_btnNewButton_1.insets = new Insets(0, 0, 5, 5); gbc_btnNewButton_1.gridx = 0; gbc_btnNewButton_1.gridy = 1; panel_1.add(btnNewButton_1, gbc_btnNewButton_1); JButton btnNoDateData = new JButton("No Date Data"); btnNoDateData.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { textFieldVerbDate.setText("[No date data]"); } }); GridBagConstraints gbc_btnNoDateData = new GridBagConstraints(); gbc_btnNoDateData.fill = GridBagConstraints.HORIZONTAL; gbc_btnNoDateData.insets = new Insets(0, 0, 5, 5); gbc_btnNoDateData.gridx = 1; gbc_btnNoDateData.gridy = 1; panel_1.add(btnNoDateData, gbc_btnNoDateData); JButton btnLabelTruncatedIn = new JButton("Label Truncated in Image"); btnLabelTruncatedIn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { appendToQuestions(Verbatim.TRUNCATED_BY_IMAGE); } }); GridBagConstraints gbc_btnLabelTruncatedIn = new GridBagConstraints(); gbc_btnLabelTruncatedIn.insets = new Insets(0, 0, 5, 5); gbc_btnLabelTruncatedIn.anchor = GridBagConstraints.NORTHWEST; gbc_btnLabelTruncatedIn.gridx = 0; gbc_btnLabelTruncatedIn.gridy = 2; panel_1.add(btnLabelTruncatedIn, gbc_btnLabelTruncatedIn); JButton btnNoCollectorData = new JButton("No Collector Data"); btnNoCollectorData.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { textFieldVerbCollector.setText("[No collector data]"); } }); GridBagConstraints gbc_btnNoCollectorData = new GridBagConstraints(); gbc_btnNoCollectorData.insets = new Insets(0, 0, 5, 5); gbc_btnNoCollectorData.gridx = 1; gbc_btnNoCollectorData.gridy = 2; panel_1.add(btnNoCollectorData, gbc_btnNoCollectorData); JButton btnNoPinLabels = new JButton("No Pin Labels"); btnNoPinLabels.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { appendToQuestions(Verbatim.NO_PIN_LABELS); } }); GridBagConstraints gbc_btnNoPinLabels = new GridBagConstraints(); gbc_btnNoPinLabels.insets = new Insets(0, 0, 0, 5); gbc_btnNoPinLabels.gridx = 0; gbc_btnNoPinLabels.gridy = 3; panel_1.add(btnNoPinLabels, gbc_btnNoPinLabels); } { JPanel panel = new JPanel(); contentPanel.add(panel, BorderLayout.CENTER); panel.setLayout(new BorderLayout(0, 0)); panel.add(getImagePanePinLabels()); } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.LEFT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); btnPrevious = new JButton("Previous"); btnPrevious.setEnabled(false); if (specimenControler != null && specimenControler.isInTable()) { btnPrevious.setEnabled(true); } btnPrevious.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { save(); if (specimenControler.previousSpecimenInTable()) { specimen = specimenControler.getSpecimen(); setValues(); } } }); buttonPane.add(btnPrevious); btnNext = new JButton("Next"); btnNext.setEnabled(false); if (specimenControler != null && specimenControler.isInTable()) { btnNext.setEnabled(true); } btnNext.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { save(); if (specimenControler.nextSpecimenInTable()) { specimen = specimenControler.getSpecimen(); setValues(); } } }); buttonPane.add(btnNext); { JButton okButton = new JButton("OK"); okButton.setActionCommand("OK"); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (save()) { setVisible(false); } } }); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("Cancel"); cancelButton.setActionCommand("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }); buttonPane.add(cancelButton); } } }
From source file:com.prezerak.windmill.gui.AveragesPanel.java
private void initialize() { setLayout(new BorderLayout(0, 0)); JPanel controlsPanel = new JPanel(); controlsPanel.setBackground(UIManager.getColor("Button.background")); controlsPanel.setBorder(null);/*from w ww. j a v a2 s. c o m*/ add(controlsPanel, BorderLayout.SOUTH); controlsPanel.setLayout(new FormLayout(new ColumnSpec[] { FormFactory.LABEL_COMPONENT_GAP_COLSPEC, ColumnSpec.decode("100px"), FormFactory.UNRELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.UNRELATED_GAP_COLSPEC, ColumnSpec.decode("101px"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("69px"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("left:max(46dlu;default)"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(25dlu;default)"), }, new RowSpec[] { FormFactory.NARROW_LINE_GAP_ROWSPEC, RowSpec.decode("23px"), FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("25px"), })); JButton btnReport = new JButton("Wind Report"); controlsPanel.add(btnReport, "2, 2, fill, fill"); btnReport.addActionListener(this); btnReport.setFont(new Font("Tahoma", Font.PLAIN, 11)); btnReport.setActionCommand("Report"); btnAlarmReport = new JButton("Alarm Report"); btnAlarmReport.setActionCommand("Alarm Report"); btnAlarmReport.addActionListener(this); btnAlarmReport.setFont(new Font("Tahoma", Font.PLAIN, 11)); controlsPanel.add(btnAlarmReport, "4, 2"); rdbtnVelocity = new JRadioButton("velocity"); controlsPanel.add(rdbtnVelocity, "10, 2, left, default"); rdbtnVelocity.setFont(new Font("Tahoma", Font.PLAIN, 11)); rdbtnVelocity.setSelected(true); rdbtnVelocity.addItemListener(this); rdbtnDirection = new JRadioButton("direction"); controlsPanel.add(rdbtnDirection, "12, 2, left, default"); rdbtnDirection.setFont(new Font("Tahoma", Font.PLAIN, 11)); rdbtnDirection.setSelected(true); rdbtnDirection.addItemListener(this); JButton btnPrintGraph = new JButton("Print Graph"); controlsPanel.add(btnPrintGraph, "2, 4, fill, top"); btnPrintGraph.setFont(new Font("Tahoma", Font.PLAIN, 11)); btnPrintGraph.setActionCommand("Print Graph"); btnPrintGraph.addActionListener(this); JButton btnBackToReal = new JButton("Back to Real Time "); controlsPanel.add(btnBackToReal, "4, 4, fill, top"); btnBackToReal.setFont(new Font("Tahoma", Font.PLAIN, 11)); btnBackToReal.setActionCommand("Back to Real"); btnBackToReal.addActionListener(this); rdbtnGust = new JRadioButton("Gust"); rdbtnGust.setSelected(true); rdbtnGust.addItemListener(this); rdbtnGust.setFont(new Font("Tahoma", Font.PLAIN, 11)); controlsPanel.add(rdbtnGust, "10, 4, left, default"); rdbtnHigh = new JRadioButton("High"); rdbtnHigh.setSelected(true); rdbtnHigh.addItemListener(this); rdbtnHigh.setFont(new Font("Tahoma", Font.PLAIN, 11)); controlsPanel.add(rdbtnHigh, "12, 4, left, default"); rdbtnHigher = new JRadioButton("Higher"); rdbtnHigher.setSelected(true); rdbtnHigher.setFont(new Font("Tahoma", Font.PLAIN, 11)); rdbtnHigher.addItemListener(this); controlsPanel.add(rdbtnHigher, "14, 4, left, default"); }