List of usage examples for javax.swing JButton setAction
@BeanProperty(visualUpdate = true, description = "the Action instance connected with this ActionEvent source") public void setAction(Action a)
Action
. From source file:cl.almejo.vsim.gui.SimWindow.java
private JButton newToolbarButton(Action action) { JButton button = new JButton(); button.setAction(action); button.setText(""); return button; }
From source file:org.geopublishing.atlasViewer.swing.AtlasChartJPanel.java
/** * Creates a {@link JToolBar} that has buttons to interact with the Chart * and it's SelectionModel./* ww w . ja v a 2 s . com*/ * * @return */ public JToolBar getToolBar() { if (toolBar == null) { toolBar = new JToolBar(); toolBar.setFloatable(false); ButtonGroup bg = new ButtonGroup(); /** * Add an Action to ZOOM/MOVE in the chart */ JToggleButton zoomToolButton = new SmallToggleButton(new AbstractAction("", ICON_ZOOM) { @Override public void actionPerformed(ActionEvent e) { getSelectableChartPanel().setWindowSelectionMode(WindowSelectionMode.ZOOM_IN_CHART); } }, GpCoreUtil.R("AtlasChartJPanel.zoom.tt")); toolBar.add(zoomToolButton); bg.add(zoomToolButton); toolBar.addSeparator(); /** * Add an Action not change the selection but just move through the * chart */ JToggleButton setSelectionButton = new SmallToggleButton(new AbstractAction("", ICON_SELECTION_SET) { @Override public void actionPerformed(ActionEvent e) { getSelectableChartPanel().setWindowSelectionMode(WindowSelectionMode.SELECT_SET); } }); setSelectionButton.setToolTipText(MapPaneToolBar.R("MapPaneButtons.Selection.SetSelection.TT")); toolBar.add(setSelectionButton); bg.add(setSelectionButton); /** * Add an Action to ADD the selection. */ JToggleButton addSelectionButton = new SmallToggleButton(new AbstractAction("", ICON_SELECTION_ADD) { @Override public void actionPerformed(ActionEvent e) { getSelectableChartPanel().setWindowSelectionMode(WindowSelectionMode.SELECT_ADD); } }); addSelectionButton.setToolTipText(MapPaneToolBar.R("MapPaneButtons.Selection.AddSelection.TT")); toolBar.add(addSelectionButton); bg.add(addSelectionButton); /** * Add an Action to REMOVE the selection. */ JToggleButton removeSelectionButton = new SmallToggleButton( new AbstractAction("", ICON_SELECTION_REMOVE) { @Override public void actionPerformed(ActionEvent e) { getSelectableChartPanel().setWindowSelectionMode(WindowSelectionMode.SELECT_REMOVE); } }); removeSelectionButton.setToolTipText(MapPaneToolBar.R("MapPaneButtons.Selection.RemoveSelection.TT")); toolBar.add(removeSelectionButton); bg.add(removeSelectionButton); toolBar.addSeparator(); /** * Add a normal Button to clear the selection. The Chart's selection * models are cleared. If a relation to a JMapPane exists, they will * be synchronized. */ final SmallButton clearSelectionButton = new SmallButton(new AbstractAction("", ICON_SELECTION_CLEAR) { @Override public void actionPerformed(ActionEvent e) { // getSelectionModel().clearSelection(); // get the selectionmodel(s) of the chart List<FeatureDatasetSelectionModel<?, ?, ?>> datasetSelectionModelFor = FeatureChartUtil .getFeatureDatasetSelectionModelFor(getSelectableChartPanel().getChart()); for (FeatureDatasetSelectionModel dsm : datasetSelectionModelFor) { dsm.clearSelection(); } } }, MapPaneToolBar.R("MapPaneButtons.Selection.ClearSelection.TT")); { // Add listeners to the selection model, so we knwo when to // disable/enable the button // get the selectionmodel(s) of the chart List<FeatureDatasetSelectionModel<?, ?, ?>> datasetSelectionModelFor = FeatureChartUtil .getFeatureDatasetSelectionModelFor(getSelectableChartPanel().getChart()); for (final FeatureDatasetSelectionModel selModel : datasetSelectionModelFor) { DatasetSelectionListener listener_ClearSelectionButtonEnbled = new DatasetSelectionListener() { @Override public void selectionChanged(DatasetSelectionChangeEvent e) { if (!e.getSource().getValueIsAdjusting()) { // Update the clearSelectionButton clearSelectionButton.setEnabled(selModel.getSelectedFeatures().size() > 0); } } }; insertedListeners.add(listener_ClearSelectionButtonEnbled); selModel.addSelectionListener(listener_ClearSelectionButtonEnbled); clearSelectionButton.setEnabled(selModel.getSelectedFeatures().size() > 0); } } toolBar.add(clearSelectionButton); toolBar.addSeparator(); /** * Add a normal Button which opens the Chart'S print dialog */ SmallButton printChartButton = new SmallButton(new AbstractAction("", Icons.ICON_PRINT_24) { @Override public void actionPerformed(ActionEvent e) { getSelectableChartPanel().createChartPrintJob(); } }); printChartButton.setToolTipText(GpCoreUtil.R("AtlasChartJPanel.PrintChartButton.TT")); toolBar.add(printChartButton); /** * Add a normal Button which opens the Chart's export/save dialog */ SmallButton saveChartAction = new SmallButton(new AbstractAction("", Icons.ICON_SAVEAS_24) { @Override public void actionPerformed(ActionEvent e) { try { getSelectableChartPanel().doSaveAs(); } catch (IOException e1) { LOGGER.info("Saving a chart to file failed", e1); ExceptionDialog.show(AtlasChartJPanel.this, e1); } } }); saveChartAction.setToolTipText(GpCoreUtil.R("AtlasChartJPanel.SaveChartButton.TT")); toolBar.add(saveChartAction); // // A JButton to open the attribute table // { final JButton openTable = new JButton(); openTable.setAction(new AbstractAction(GpCoreUtil.R("LayerToolMenu.table"), Icons.ICON_TABLE) { @Override public void actionPerformed(final ActionEvent e) { AVDialogManager.dm_AttributeTable.getInstanceFor(styledLayer, AtlasChartJPanel.this, styledLayer, mapLegend); } }); toolBar.addSeparator(); toolBar.add(openTable); } /* * Select/set data points button is activated by default */ getSelectableChartPanel().setWindowSelectionMode(WindowSelectionMode.SELECT_SET); setSelectionButton.setSelected(true); } return toolBar; }
From source file:org.simbrain.plot.projection.ProjectionGui.java
/** * Construct the Projection GUI./*w w w . j a v a 2 s.c o m*/ */ 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:com.anrisoftware.prefdialog.simpledialog.SimpleDialog.java
private void addRestoreButton() { JButton restoreButton = getRestoreButton(); restoreAction.setDialog(this); restoreAction.setTexts(texts);/*from ww w . java 2 s.com*/ restoreButton.setVisible(true); restoreButton.setAction(restoreAction); }
From source file:com.anrisoftware.prefdialog.simpledialog.SimpleDialog.java
private void addApproveButton() { JButton approveButton = getApproveButton(); approveAction.setDialog(this); approveAction.setTexts(texts);/* w w w . j a v a 2 s . c o m*/ approveButton.setVisible(true); approveButton.setAction(approveAction); }
From source file:com.anrisoftware.prefdialog.simpledialog.SimpleDialog.java
private void readdRestoreButton() { JButton cancelButton = getCancelButton(); JButton restoreButton = getRestoreButton(); JPanel buttonsPanel = dialogPanel.getButtonsPanel(); restoreAction.setDialog(this); restoreAction.setTexts(texts);/*from ww w. j a v a 2 s . co m*/ restoreButton.setVisible(true); restoreButton.setAction(restoreAction); buttonsPanel.remove(cancelButton); buttonsPanel.add(restoreButton); buttonsPanel.add(dialogPanel.getRestoreStrut()); buttonsPanel.add(cancelButton); buttonsPanel.validate(); }
From source file:com.anrisoftware.prefdialog.simpledialog.SimpleDialog.java
private void readdApproveButton() { JButton cancelButton = getCancelButton(); JButton approveButton = getApproveButton(); JPanel buttonsPanel = dialogPanel.getButtonsPanel(); approveAction.setDialog(this); approveAction.setTexts(texts);/*from w ww .j a va 2 s . com*/ approveButton.setVisible(true); approveButton.setAction(approveAction); buttonsPanel.remove(cancelButton); buttonsPanel.add(approveButton); buttonsPanel.add(dialogPanel.getApproveStrut()); buttonsPanel.add(cancelButton); buttonsPanel.validate(); }
From source file:org.fhaes.fhsamplesize.view.FHSampleSize.java
/** * Initialize GUI components.//from w w w .j a v a2 s.c o m */ @SuppressWarnings({ "rawtypes", "unchecked" }) private void initGUI() { App.init(); // setBounds(100, 100, 972, 439); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setIconImage(Builder.getApplicationIcon()); setTitle("Sample Size Analysis"); getContentPane().setLayout(new MigLayout("", "[1136px,grow,fill]", "[30px][405px,grow]")); JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); getContentPane().add(toolBar, "cell 0 0,growx,aligny top"); JToolBarButton btnOpen = new JToolBarButton(actionBrowse); btnOpen.setIcon(Builder.getImageIcon("fileopen.png")); toolBar.add(btnOpen); JToolBarButton btnSave = new JToolBarButton(actionSaveTable); btnSave.setIcon(Builder.getImageIcon("save.png")); toolBar.add(btnSave); JToolBarButton btnExportPDF = new JToolBarButton(actionExportPDF); btnExportPDF.setIcon(Builder.getImageIcon("pdf.png")); toolBar.add(btnExportPDF); JToolBarButton btnExportPNG = new JToolBarButton(actionExportPNG); btnExportPNG.setIcon(Builder.getImageIcon("formatpng.png")); toolBar.add(btnExportPNG); toolBar.addSeparator(); JToolBarButton btnRun = new JToolBarButton(actionRun); btnRun.setIcon(Builder.getImageIcon("run.png")); toolBar.add(btnRun); JPanel panelMain = new JPanel(); getContentPane().add(panelMain, "cell 0 1,grow"); panelMain.setLayout(new BorderLayout(0, 0)); JSplitPane splitPaneMain = new JSplitPane(); splitPaneMain.setOneTouchExpandable(true); panelMain.add(splitPaneMain); JPanel panelParameters = new JPanel(); splitPaneMain.setLeftComponent(panelParameters); panelParameters.setLayout(new MigLayout("", "[grow,right]", "[][][][193.00,grow,fill][]")); JPanel panelInput = new JPanel(); panelInput.setBorder(new TitledBorder(null, "Input", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panelParameters.add(panelInput, "cell 0 0,grow"); panelInput.setLayout(new MigLayout("", "[100px:100px:180px,right][grow,fill][]", "[]")); JLabel lblInputFile = new JLabel("Input file:"); panelInput.add(lblInputFile, "cell 0 0"); txtInputFile = new JTextField(); panelInput.add(txtInputFile, "cell 1 0,growx"); txtInputFile.setActionCommand("NewFileTyped"); txtInputFile.addActionListener(this); txtInputFile.setColumns(10); JButton btnBrowse = new JButton(""); panelInput.add(btnBrowse, "cell 2 0"); btnBrowse.setAction(actionBrowse); btnBrowse.setText(""); btnBrowse.setIcon(Builder.getImageIcon("fileopen16.png")); btnBrowse.setPreferredSize(new Dimension(25, 25)); btnBrowse.setMaximumSize(new Dimension(25, 25)); btnBrowse.putClientProperty("JButton.buttonType", "segmentedTextured"); btnBrowse.putClientProperty("JButton.segmentPosition", "middle"); JPanel panelAnalysisOptions = new JPanel(); panelAnalysisOptions.setBorder(new TitledBorder(null, "Analysis and filtering options", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panelParameters.add(panelAnalysisOptions, "cell 0 1,grow"); panelAnalysisOptions.setLayout(new MigLayout("", "[100px:100px:180px,right][grow][][]", "[][][][][]")); JLabel lblEventTypes = new JLabel("Event type:"); panelAnalysisOptions.add(lblEventTypes, "cell 0 0"); cboEventType = new JComboBox(); panelAnalysisOptions.add(cboEventType, "cell 1 0 3 1"); cboEventType.setModel(new DefaultComboBoxModel(EventTypeToProcess.values())); new EventTypeWrapper(cboEventType, PrefKey.EVENT_TYPE_TO_PROCESS, EventTypeToProcess.FIRE_EVENT); chkCommonYears = new JCheckBox("<html>Only analyze years all series have in common"); chkCommonYears.setEnabled(false); new CheckBoxWrapper(chkCommonYears, PrefKey.SSIZ_CHK_COMMON_YEARS, false); panelAnalysisOptions.add(chkCommonYears, "cell 1 1 3 1"); chkExcludeSeriesWithNoEvents = new JCheckBox("<html>Exclude series/segments with no events"); chkExcludeSeriesWithNoEvents.setEnabled(false); new CheckBoxWrapper(chkExcludeSeriesWithNoEvents, PrefKey.SSIZ_CHK_EXCLUDE_SERIES_WITH_NO_EVENTS, false); panelAnalysisOptions.add(chkExcludeSeriesWithNoEvents, "cell 1 2 3 1"); JLabel lblThresholdType = new JLabel("Threshold:"); panelAnalysisOptions.add(lblThresholdType, "cell 0 3"); cboThresholdType = new JComboBox(); panelAnalysisOptions.add(cboThresholdType, "cell 1 3"); cboThresholdType.setModel(new DefaultComboBoxModel(FireFilterType.values())); new FireFilterTypeWrapper(cboThresholdType, PrefKey.COMPOSITE_FILTER_TYPE_WITH_ALL_TREES, FireFilterType.NUMBER_OF_EVENTS); JLabel label = new JLabel(">="); panelAnalysisOptions.add(label, "flowx,cell 2 3"); spnThresholdValueGT = new JSpinner(); panelAnalysisOptions.add(spnThresholdValueGT, "cell 3 3"); spnThresholdValueGT.setModel(new SpinnerNumberModel(1, 1, 999, 1)); new SpinnerWrapper(spnThresholdValueGT, PrefKey.COMPOSITE_FILTER_VALUE, 1); chkEnableLessThan = new JCheckBox(""); chkEnableLessThan.setActionCommand("LessThanThresholdStatus"); chkEnableLessThan.addActionListener(this); panelAnalysisOptions.add(chkEnableLessThan, "flowx,cell 1 4,alignx right"); lblLessThan = new JLabel("<="); lblLessThan.setEnabled(false); panelAnalysisOptions.add(lblLessThan, "cell 2 4"); spnThresholdValueLT = new JSpinner(); spnThresholdValueLT.setEnabled(false); spnThresholdValueLT.setModel(new SpinnerNumberModel(1, 1, 999, 1)); panelAnalysisOptions.add(spnThresholdValueLT, "cell 3 4"); lblAnd = new JLabel("and"); panelAnalysisOptions.add(lblAnd, "cell 1 4"); JPanel panelSimulations = new JPanel(); panelSimulations.setBorder( new TitledBorder(null, "Simulations", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panelParameters.add(panelSimulations, "cell 0 2,grow"); panelSimulations.setLayout(new MigLayout("", "[100px:100px:180px,right][fill]", "[][][]")); JLabel lblSimulations = new JLabel("Simulations:"); panelSimulations.add(lblSimulations, "cell 0 0"); spnSimulations = new JSpinner(); panelSimulations.add(spnSimulations, "cell 1 0"); spnSimulations.setModel(new SpinnerNumberModel(new Integer(1000), new Integer(1), null, new Integer(1))); new SpinnerWrapper(spnSimulations, PrefKey.SSIZ_SIMULATION_COUNT, 1000); JLabel lblSeedNumber = new JLabel("Seed number:"); panelSimulations.add(lblSeedNumber, "cell 0 1"); spnSeed = new JSpinner(); panelSimulations.add(spnSeed, "cell 1 1"); spnSeed.setModel(new SpinnerNumberModel(new Integer(30188), null, null, new Integer(1))); new SpinnerWrapper(spnSeed, PrefKey.SSIZ_SEED_NUMBER, 30188); JLabel lblResampling = new JLabel("Resampling:"); panelSimulations.add(lblResampling, "cell 0 2"); cboResampling = new JComboBox(); panelSimulations.add(cboResampling, "cell 1 2"); cboResampling .setModel(new DefaultComboBoxModel(new String[] { "With replacement", "Without replacement" })); new ResamplingTypeWrapper(cboResampling, PrefKey.SSIZ_RESAMPLING_TYPE, ResamplingType.WITH_REPLACEMENT); segmentationPanel = new SegmentationPanel(); segmentationPanel.chkSegmentation.setText("Process subset or segments of dataset?"); segmentationPanel.chkSegmentation.setEnabled(false); panelParameters.add(segmentationPanel, "cell 0 3,growx"); JPanel panel_3 = new JPanel(); panelParameters.add(panel_3, "cell 0 4,grow"); panel_3.setLayout(new MigLayout("", "[left][grow][right]", "[]")); JButton btnReset = new JButton("Reset"); btnReset.setActionCommand("Reset"); btnReset.addActionListener(this); panel_3.add(btnReset, "cell 0 0,grow"); JButton btnRunAnalysis = new JButton("Run Analysis"); btnRunAnalysis.setAction(actionRun); panel_3.add(btnRunAnalysis, "cell 2 0,grow"); JPanel panelResults = new JPanel(); splitPaneMain.setRightComponent(panelResults); panelResults.setLayout(new BorderLayout(0, 0)); splitPaneResults = new JSplitPane(); splitPaneResults.setResizeWeight(0.5); splitPaneResults.setOneTouchExpandable(true); splitPaneResults.setDividerLocation(0.5d); panelResults.add(splitPaneResults, BorderLayout.CENTER); splitPaneResults.setOrientation(JSplitPane.VERTICAL_SPLIT); JPanel panelResultsTop = new JPanel(); splitPaneResults.setLeftComponent(panelResultsTop); panelResultsTop.setLayout(new BorderLayout(0, 0)); JPanel panelChartOptions = new JPanel(); panelChartOptions.setBackground(Color.WHITE); panelResultsTop.add(panelChartOptions, BorderLayout.SOUTH); panelChartOptions.setLayout(new MigLayout("", "[][][][][][grow][grow]", "[15px,center]")); JLabel lblNewLabel = new JLabel("Plot:"); panelChartOptions.add(lblNewLabel, "cell 0 0,alignx trailing,aligny center"); cboChartMetric = new JComboBox(); cboChartMetric.setEnabled(false); cboChartMetric.setModel(new DefaultComboBoxModel(MiddleMetric.values())); panelChartOptions.add(cboChartMetric, "cell 1 0,growx"); cboChartMetric.setBackground(Color.WHITE); JLabel lblOfSegment = new JLabel("of segment:"); panelChartOptions.add(lblOfSegment, "cell 2 0,alignx trailing"); cboSegment = new JComboBox(); cboSegment.setBackground(Color.WHITE); cboSegment.setActionCommand("UpdateChart"); cboSegment.addActionListener(this); panelChartOptions.add(cboSegment, "cell 3 0,growx"); cboChartMetric.setActionCommand("UpdateChart"); JLabel lblWithAsymptoteType = new JLabel("with asymptote type:"); panelChartOptions.add(lblWithAsymptoteType, "cell 4 0,alignx trailing"); JComboBox comboBox = new JComboBox(); comboBox.setEnabled(false); comboBox.setModel(new DefaultComboBoxModel(new String[] { "none", "Weibull", "Michaelis-Menten", "Modified Michaelis-Menten", "Logistic", "Modified exponential" })); comboBox.setBackground(Color.WHITE); panelChartOptions.add(comboBox, "cell 5 0,growx"); cboChartMetric.addActionListener(this); panelChart = new JPanel(); panelChart.setMinimumSize(new Dimension(200, 200)); panelResultsTop.add(panelChart, BorderLayout.CENTER); panelChart.setLayout(new BorderLayout(0, 0)); panelChart.setBackground(Color.WHITE); JTabbedPane panelResultsBottom = new JTabbedPane(JTabbedPane.BOTTOM); splitPaneResults.setRightComponent(panelResultsBottom); simulationsTable = new SSIZResultsTable(); simulationsTable.setEnabled(false); simulationsTable.addMouseListener(new TablePopClickListener()); simulationsTable.setVisibleRowCount(10); adapter = new JTableSpreadsheetByRowAdapter(simulationsTable); scrollPaneSimulations = new JScrollPane(); panelResultsBottom.addTab("Simulations", null, scrollPaneSimulations, null); scrollPaneSimulations.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPaneSimulations.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollPaneSimulations.setViewportView(simulationsTable); JPanel panelAsymptote = new JPanel(); asymptoteTable = new AsymptoteTable(); asymptoteTable.setEnabled(false); // asymptoteTable.addMouseListener(new TablePopClickListener()); asymptoteTable.setVisibleRowCount(10); scrollPaneAsymptote = new JScrollPane(); scrollPaneAsymptote.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPaneAsymptote.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollPaneAsymptote.setViewportView(asymptoteTable); panelAsymptote.setLayout(new BorderLayout()); panelAsymptote.add(scrollPaneAsymptote, BorderLayout.CENTER); panelResultsBottom.addTab("Asymptote", null, panelAsymptote, null); // Disable asymptote tab until it is implemented panelResultsBottom.setEnabledAt(1, false); panelProgressBar = new JPanel(); panelProgressBar.setLayout(new BorderLayout()); btnCancelAnalysis = new JButton("Cancel"); btnCancelAnalysis.setIcon(Builder.getImageIcon("delete.png")); btnCancelAnalysis.setVisible(false); btnCancelAnalysis.setActionCommand("CancelAnalysis"); btnCancelAnalysis.addActionListener(this); progressBar = new JProgressBar(); panelProgressBar.add(progressBar, BorderLayout.CENTER); panelProgressBar.add(btnCancelAnalysis, BorderLayout.EAST); progressBar.setStringPainted(true); fileDialogWasUsed = false; mouseListenersActive = false; this.setGUIForFHFileReader(); this.setGUIForThresholdStatus(); pack(); this.setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH); setVisible(true); }
From source file:Installer.java
public Installer(File targetDir) { ToolTipManager.sharedInstance().setDismissDelay(Integer.MAX_VALUE); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JPanel logoSplash = new JPanel(); logoSplash.setLayout(new BoxLayout(logoSplash, BoxLayout.Y_AXIS)); try {//from w ww . jav a 2s .c o m // Read png BufferedImage image; image = ImageIO.read(Installer.class.getResourceAsStream("logo.png")); ImageIcon icon = new ImageIcon(image); JLabel logoLabel = new JLabel(icon); logoLabel.setAlignmentX(CENTER_ALIGNMENT); logoLabel.setAlignmentY(CENTER_ALIGNMENT); logoLabel.setSize(image.getWidth(), image.getHeight()); if (!QUIET_DEV) // VIVE - hide oculus logo logoSplash.add(logoLabel); } catch (IOException e) { } catch (IllegalArgumentException e) { } userHomeDir = System.getProperty("user.home", "."); osType = System.getProperty("os.name").toLowerCase(); if (osType.contains("win")) { isWindows = true; appDataDir = System.getenv("APPDATA"); } version = "UNKNOWN"; try { InputStream ver = Installer.class.getResourceAsStream("version"); if (ver != null) { String[] tok = new BufferedReader(new InputStreamReader(ver)).readLine().split(":"); if (tok.length > 0) { jar_id = tok[0]; version = tok[1]; } } } catch (IOException e) { } // Read release notes, save to file String tmpFileName = System.getProperty("java.io.tmpdir") + releaseNotePathAddition + "Vivecraft" + version.toLowerCase() + "_release_notes.txt"; releaseNotes = new File(tmpFileName); InputStream is = Installer.class.getResourceAsStream("release_notes.txt"); if (!copyInputStreamToFile(is, releaseNotes)) { releaseNotes = null; } JLabel tag = new JLabel("Welcome! This will install Vivecraft " + version); tag.setAlignmentX(CENTER_ALIGNMENT); tag.setAlignmentY(CENTER_ALIGNMENT); logoSplash.add(tag); logoSplash.add(Box.createRigidArea(new Dimension(5, 20))); tag = new JLabel("Select path to minecraft. (The default here is almost always what you want.)"); tag.setAlignmentX(CENTER_ALIGNMENT); tag.setAlignmentY(CENTER_ALIGNMENT); logoSplash.add(tag); logoSplash.setAlignmentX(CENTER_ALIGNMENT); logoSplash.setAlignmentY(TOP_ALIGNMENT); this.add(logoSplash); JPanel entryPanel = new JPanel(); entryPanel.setLayout(new BoxLayout(entryPanel, BoxLayout.X_AXIS)); Installer.targetDir = targetDir; selectedDirText = new JTextField(); selectedDirText.setEditable(false); selectedDirText.setToolTipText("Path to minecraft"); selectedDirText.setColumns(30); entryPanel.add(selectedDirText); JButton dirSelect = new JButton(); dirSelect.setAction(new FileSelectAction()); dirSelect.setText("..."); dirSelect.setToolTipText("Select an alternative minecraft directory"); entryPanel.add(dirSelect); entryPanel.setAlignmentX(LEFT_ALIGNMENT); entryPanel.setAlignmentY(TOP_ALIGNMENT); infoLabel = new JLabel(); infoLabel.setHorizontalTextPosition(JLabel.LEFT); infoLabel.setVerticalTextPosition(JLabel.TOP); infoLabel.setAlignmentX(LEFT_ALIGNMENT); infoLabel.setAlignmentY(TOP_ALIGNMENT); infoLabel.setVisible(false); fileEntryPanel = new JPanel(); fileEntryPanel.setLayout(new BoxLayout(fileEntryPanel, BoxLayout.Y_AXIS)); fileEntryPanel.add(infoLabel); fileEntryPanel.add(entryPanel); fileEntryPanel.setAlignmentX(CENTER_ALIGNMENT); fileEntryPanel.setAlignmentY(TOP_ALIGNMENT); this.add(fileEntryPanel); this.add(Box.createVerticalStrut(5)); JPanel optPanel = new JPanel(); optPanel.setLayout(new BoxLayout(optPanel, BoxLayout.Y_AXIS)); optPanel.setAlignmentX(LEFT_ALIGNMENT); optPanel.setAlignmentY(TOP_ALIGNMENT); //Add forge options JPanel forgePanel = new JPanel(); forgePanel.setLayout(new BoxLayout(forgePanel, BoxLayout.X_AXIS)); //Create forge: no/yes buttons useForge = new JCheckBox(); AbstractAction actf = new updateActionF(); actf.putValue(AbstractAction.NAME, "Install Vivecraft with Forge " + FORGE_VERSION); useForge.setAction(actf); forgeVersion = new JComboBox(); if (!ALLOW_FORGE_INSTALL) useForge.setEnabled(false); useForge.setToolTipText( "<html>" + "If checked, installs Vivecraft with Forge support. The correct version of Forge<br>" + "(as displayed) must already be installed.<br>" + "</html>"); //Add "yes" and "which version" to the forgePanel useForge.setAlignmentX(LEFT_ALIGNMENT); forgeVersion.setAlignmentX(LEFT_ALIGNMENT); forgePanel.add(useForge); //forgePanel.add(forgeVersion); // Profile creation / update support createProfile = new JCheckBox("", true); AbstractAction actp = new updateActionP(); actp.putValue(AbstractAction.NAME, "Create Vivecraft launcher profile"); createProfile.setAction(actp); createProfile.setAlignmentX(LEFT_ALIGNMENT); createProfile.setSelected(true); createProfile.setToolTipText("<html>" + "If checked, if a Vivecraft profile doesn't already exist within the Minecraft launcher<br>" + "one is added. Then the profile is selected, and this Vivecraft version is set as the<br>" + "current version.<br>" + "</html>"); useShadersMod = new JCheckBox(); useShadersMod.setAlignmentX(LEFT_ALIGNMENT); if (!ALLOW_SHADERSMOD_INSTALL) useShadersMod.setEnabled(false); AbstractAction acts = new updateActionSM(); acts.putValue(AbstractAction.NAME, "Install Vivecraft with ShadersMod 2.3.29"); useShadersMod.setAction(acts); useShadersMod.setToolTipText("<html>" + "If checked, sets the vivecraft profile to use ShadersMod <br>" + "support." + "</html>"); useHydra = new JCheckBox("Razer Hydra support", false); useHydra.setAlignmentX(LEFT_ALIGNMENT); if (!ALLOW_HYDRA_INSTALL) useHydra.setEnabled(false); useHydra.setToolTipText("<html>" + "If checked, installs the additional Razor Hydra native library required for Razor Hydra<br>" + "support." + "</html>"); useHrtf = new JCheckBox("Enable binaural audio (Only needed once per PC)", false); useHrtf.setToolTipText("<html>" + "If checked, the installer will create the configuration file needed for OpenAL HRTF<br>" + "ear-aware sound in Minecraft (and other games).<br>" + " If the file has previously been created, you do not need to check this again.<br>" + " NOTE: Your sound card's output MUST be set to 44.1Khz.<br>" + " WARNING, will overwrite " + (isWindows ? (appDataDir + "\\alsoft.ini") : (userHomeDir + "/.alsoftrc")) + "!<br>" + " Delete the " + (isWindows ? "alsoft.ini" : "alsoftrc") + " file to disable HRTF again." + "</html>"); useHrtf.setAlignmentX(LEFT_ALIGNMENT); //Add option panels option panel forgePanel.setAlignmentX(LEFT_ALIGNMENT); //optPanel.add(forgePanel); //optPanel.add(useShadersMod); optPanel.add(createProfile); optPanel.add(useHrtf); this.add(optPanel); this.add(Box.createRigidArea(new Dimension(5, 20))); instructions = new JLabel("", SwingConstants.CENTER); instructions.setAlignmentX(CENTER_ALIGNMENT); instructions.setAlignmentY(TOP_ALIGNMENT); instructions.setForeground(Color.RED); instructions.setPreferredSize(new Dimension(20, 40)); this.add(instructions); this.add(Box.createVerticalGlue()); JLabel github = linkify("Vivecraft is open source. find it on Github", "https://github.com/jrbudda/Vivecraft_111", "Vivecraft 1.11 Github"); JLabel wiki = linkify("Vivecraft home page", "http://www.vivecraft.org", "Vivecraft Home"); JLabel donate = linkify("If you think Vivecraft is awesome, please consider donating.", "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=JVBJLN5HJJS52&lc=US&item_name=jrbudda¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted)", "jrbudda's Paypal"); JLabel optifine = linkify("Vivecraft includes OptiFine for performance. Consider donating to them as well.", "http://optifine.net/donate.php", "http://optifine.net/donate.php"); github.setAlignmentX(CENTER_ALIGNMENT); github.setHorizontalAlignment(SwingConstants.CENTER); wiki.setAlignmentX(CENTER_ALIGNMENT); wiki.setHorizontalAlignment(SwingConstants.CENTER); donate.setAlignmentX(CENTER_ALIGNMENT); donate.setHorizontalAlignment(SwingConstants.CENTER); optifine.setAlignmentX(CENTER_ALIGNMENT); optifine.setHorizontalAlignment(SwingConstants.CENTER); this.add(Box.createRigidArea(new Dimension(5, 20))); this.add(github); this.add(wiki); this.add(donate); this.add(optifine); this.setAlignmentX(LEFT_ALIGNMENT); updateFilePath(); updateInstructions(); }
From source file:org.fhaes.jsea.JSEAFrame.java
/** * Create the dialog.//from ww w.j av a2s .c o m */ public JSEAFrame(Component parent) { setupGui(); this.pack(); this.setLocationRelativeTo(parent); this.txtTimeSeriesFile.setText(""); this.txtEventListFile.setText(""); { JPanel buttonPanel = new JPanel(); contentPanel.add(buttonPanel, "cell 0 4,grow"); buttonPanel.setLayout(new MigLayout("", "[left][grow][right]", "[]")); { JButton resetButton = new JButton("Reset"); resetButton.setAction(actionReset); buttonPanel.add(resetButton, "cell 0 0,grow"); } { JButton runAnalysisButton = new JButton("Run Analysis"); runAnalysisButton.setAction(actionRun); buttonPanel.add(runAnalysisButton, "cell 2 0,grow"); } } this.setVisible(true); }