List of usage examples for javax.swing Box createHorizontalBox
public static Box createHorizontalBox()
Box
that displays its components from left to right. From source file:com.diversityarrays.kdxplore.curate.fieldview.OverviewDialog.java
@SuppressWarnings("unchecked") public OverviewDialog(Window window, String title, @SuppressWarnings("rawtypes") ComboBoxModel comboBoxModel, CurationData curationData, Transformer<TraitInstance, String> tiNameProvider, OverviewInfoProvider overviewInfoProvider, FieldViewSelectionModel fvsm, FieldLayoutTableModel fltm, CurationTableModel ctm) { super(window, title, ModalityType.MODELESS); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setAlwaysOnTop(true);//w w w . java 2s . c om this.fieldViewSelectionModel = fvsm; @SuppressWarnings({ "rawtypes" }) JComboBox activeTiCombo = new JComboBox(comboBoxModel); TraitInstanceCellRenderer tiCellRenderer = new TraitInstanceCellRenderer( curationData.getTraitColorProvider(), tiNameProvider); activeTiCombo.setRenderer(tiCellRenderer); JLabel infoLabel = new JLabel(" "); infoLabel.setBorder(new BevelBorder(BevelBorder.LOWERED)); final JFrame[] helpDialog = new JFrame[1]; Action helpAction = new AbstractAction("?") { @Override public void actionPerformed(ActionEvent e) { if (helpDialog[0] != null) { GuiUtil.restoreFrame(helpDialog[0]); } else { JFrame f = new JFrame("Overview Help"); helpDialog[0] = f; f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setAlwaysOnTop(true); f.setLocationRelativeTo(overview); String html = Overview.getOverviewHelpHtml(); JLabel label = new JLabel(html); label.setBorder(new EmptyBorder(0, 10, 0, 10)); f.setContentPane(label); f.pack(); f.setVisible(true); } } }; // Window window = GuiUtil.getOwnerWindow(FieldLayoutViewPanel.this); if (window != null) { if (window instanceof JFrame) { System.out.println("Found window: " + ((JFrame) window).getTitle()); } window.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { window.removeWindowListener(this); if (helpDialog[0] != null) { helpDialog[0].dispose(); } } }); } KDClientUtils.initAction(ImageId.HELP_24, helpAction, "Help for Overview"); Box top = Box.createHorizontalBox(); top.add(activeTiCombo); top.add(new JButton(helpAction)); overview = new Overview(overviewInfoProvider, fltm, curationData, ctm, infoLabel); overview.setActiveTraitInstance(fvsm.getActiveTraitInstance(true)); Container cp = getContentPane(); cp.add(top, BorderLayout.NORTH); // cp.add(traitLabel, BorderLayout.NORTH); cp.add(infoLabel, BorderLayout.SOUTH); cp.add(overview, BorderLayout.CENTER); pack(); // setResizable(false); // setLocationRelativeTo(showOverviewButton); // DEFAULT POSITION is "out of the way" setVisible(true); this.fieldViewSelectionModel.addListSelectionListener(listSelectionListener); addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { toFront(); } @Override public void windowClosed(WindowEvent e) { fieldViewSelectionModel.removeListSelectionListener(listSelectionListener); removeWindowListener(this); } }); }
From source file:com.diversityarrays.kdxplore.trialmgr.trait.TraitExportDialog.java
public TraitExportDialog(Window owner, List<Trait> traits) { super(owner, "Export Traits", ModalityType.APPLICATION_MODAL); this.traits = traits; setDefaultCloseOperation(DISPOSE_ON_CLOSE); setGlassPane(backgroundRunner.getBlockingPane()); JPanel mainPanel = new JPanel(); GBH gbh = new GBH(mainPanel, 2, 1, 2, 1); int y = 0;/*from www.ja va2s. com*/ gbh.add(0, y, 1, 1, GBH.NONE, 1, 1, GBH.EAST, "CSV file:"); gbh.add(1, y, 1, 1, GBH.HORZ, 2, 1, GBH.CENTER, filepathField); gbh.add(2, y, 1, 1, GBH.NONE, 1, 1, GBH.WEST, new JButton(browseAction)); ++y; exportAction.setEnabled(false); filepathField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { updateExportAction(); } @Override public void insertUpdate(DocumentEvent e) { updateExportAction(); } @Override public void changedUpdate(DocumentEvent e) { updateExportAction(); } private void updateExportAction() { exportAction.setEnabled(!Check.isEmpty(filepathField.getText().trim())); } }); File outdir = KdxplorePreferences.getInstance().getOutputDirectory(); if (outdir != null) { File outfile = new File(outdir, "traits.csv"); filepathField.setText(outfile.getPath()); } Box buttons = Box.createHorizontalBox(); buttons.add(openAfterExport); buttons.add(Box.createHorizontalGlue()); buttons.add(new JButton(cancelAction)); buttons.add(new JButton(exportAction)); Container cp = getContentPane(); cp.add(mainPanel, BorderLayout.CENTER); cp.add(buttons, BorderLayout.SOUTH); pack(); Dimension sz = getSize(); setSize(600, sz.height); }
From source file:hr.fer.zemris.vhdllab.platform.gui.dialog.save.SaveDialog.java
public SaveDialog(LocalizationSource source, SaveContext context) { super(source); Validate.notNull(context, "Save variant can't be null"); // setup label JLabel label = new JLabel(getMainMessage(source, context)); int width = DIALOG_WIDTH - 2 * BORDER; int height = LABEL_HEIGHT - 2 * BORDER; label.setPreferredSize(new Dimension(width, height)); label.setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER, BORDER)); // setup check box list list = new CheckBoxList(); width = DIALOG_WIDTH - 2 * BORDER;// w w w. ja v a 2 s. c om height = 0; // because list is a center component and it doesnt need // height list.setPreferredSize(new Dimension(width, height)); list.setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER, BORDER)); // setup select all and deselect all buttons JButton selectAll = new JButton(source.getMessage(SELECT_ALL_MESSAGE)); selectAll.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); selectAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { list.setSelectionToAll(true); } }); JButton deselectAll = new JButton(source.getMessage(DESELECT_ALL_MESSAGE)); deselectAll.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); deselectAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { list.setSelectionToAll(false); } }); Box selectBox = Box.createHorizontalBox(); selectBox.add(selectAll); selectBox.add(Box.createRigidArea(new Dimension(BORDER, BUTTON_HEIGHT))); selectBox.add(deselectAll); selectBox.setBorder(BorderFactory.createEmptyBorder(0, 0, BORDER, 0)); // setup ok and cancel buttons JButton ok = new JButton(source.getMessage(OK_MESSAGE)); ok.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeDialog(new ArrayList<File>()); } }); JButton cancel = new JButton(source.getMessage(CANCEL_MESSAGE)); cancel.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeDialog(null); } }); Box actionBox = Box.createHorizontalBox(); actionBox.add(ok); actionBox.add(Box.createRigidArea(new Dimension(BORDER, BUTTON_HEIGHT))); actionBox.add(cancel); actionBox.setBorder(BorderFactory.createEmptyBorder(BORDER, 0, BORDER, 0)); JPanel selectPanel = new JPanel(new BorderLayout()); selectPanel.add(selectBox, BorderLayout.EAST); JPanel actionPanel = new JPanel(new BorderLayout()); actionPanel.add(actionBox, BorderLayout.EAST); JCheckBox alwaysSave = new JCheckBox(source.getMessage(ALWAYS_SAVE_MESSAGE)); alwaysSave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JCheckBox checkBox = (JCheckBox) e.getSource(); Preferences preferences = Preferences.userNodeForPackage(SaveDialog.class); preferences.putBoolean(SHOULD_AUTO_SAVE, checkBox.isSelected()); } }); alwaysSave.setSelected(false); JPanel alwaysSavePanel = new JPanel(new BorderLayout()); alwaysSavePanel.add(alwaysSave, BorderLayout.WEST); JPanel lowerPanel = new JPanel(new BorderLayout()); lowerPanel.add(selectPanel, BorderLayout.NORTH); lowerPanel.add(alwaysSavePanel, BorderLayout.CENTER); lowerPanel.add(actionPanel, BorderLayout.SOUTH); this.setLayout(new BorderLayout()); JPanel messagePanel = new JPanel(new BorderLayout()); messagePanel.add(label, BorderLayout.NORTH); messagePanel.add(list, BorderLayout.CENTER); messagePanel.add(lowerPanel, BorderLayout.SOUTH); this.getContentPane().add(messagePanel, BorderLayout.CENTER); this.getRootPane().setDefaultButton(ok); this.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT)); this.setTitle(getTitle(source, context)); }
From source file:org.jdal.swing.TableEditor.java
/** * @return header//from w ww . j ava2 s . c o m */ protected Container createHeader() { JLabel label = new JLabel(getName()); label.setAlignmentX(Container.LEFT_ALIGNMENT); Box box = Box.createHorizontalBox(); box.add(label); return box; }
From source file:com.diversityarrays.update.UpdateDialog.java
public UpdateDialog(UpdateCheckRequest updateCheckRequest, UpdateCheckContext ctx, long exp_ms) { super(updateCheckRequest.owner, Msg.TITLE_UPDATE_CHECK(), ModalityType.APPLICATION_MODAL); this.updateCheckRequest = updateCheckRequest; this.updateCheckContext = ctx; setKDXploreUpdate(null);/* w ww . j av a 2 s . c om*/ installUpdateAction.setEnabled(false); cardPanel.setBorder(new EmptyBorder(20, 20, 20, 20)); progressBar.setIndeterminate(true); cardPanel.add(progressBar, CARD_PROGRESS); if (exp_ms > 0) { daysToGo = 1 + ChronoUnit.DAYS.between(new Date().toInstant(), new Date(exp_ms).toInstant()); JPanel tmp = new JPanel(new BorderLayout()); tmp.add(new JLabel(Msg.HTML_THIS_VERSION_EXPIRES_IN_N_DAYS((int) daysToGo)), BorderLayout.NORTH); tmp.add(messageLabel, BorderLayout.CENTER); cardPanel.add(tmp, CARD_MESSAGE); } else { daysToGo = 0; cardPanel.add(messageLabel, CARD_MESSAGE); } cardLayout.show(cardPanel, CARD_PROGRESS); Box buttons = Box.createHorizontalBox(); buttons.add(new JButton(closeAction)); buttons.add(new JButton(moreAction)); if (RunMode.getRunMode().isDeveloper()) { buttons.add(new JButton(installUpdateAction)); } buttons.add(Box.createHorizontalGlue()); buttons.add(backupDatabaseButton); backupDatabaseButton.setVisible(false); backupDatabaseAction.setEnabled(updateCheckContext.canBackupDatabase()); Container cp = getContentPane(); cp.add(buttons, BorderLayout.SOUTH); cp.add(cardPanel, BorderLayout.CENTER); pack(); GuiUtil.centreOnOwner(this); addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { removeWindowListener(this); checkForUpdates(updateCheckContext.getPrintStream()); } }); }
From source file:com.diversityarrays.kdxplore.trialdesign.RscriptFinderPanel.java
public RscriptFinderPanel(BackgroundRunner br, Component component, String initialScriptPath, Consumer<Either<Throwable, String>> onScriptPathChecked) { super(new BorderLayout()); backgroundRunner = br;/* w w w.java 2 s .co m*/ this.onScriptPathChecked = onScriptPathChecked; scriptPathField.setText(initialScriptPath); scriptPathField.addMouseListener(clickAdapter); Box scriptPathBox = Box.createHorizontalBox(); Consumer<Void> updateFindScriptButton = new Consumer<Void>() { @Override public void accept(Void t) { checkScriptPath.setEnabled(!scriptPathField.getText().trim().isEmpty()); } }; scriptPathBox.add(scriptPathField); scriptPathBox.add(new JButton(checkScriptPath)); scriptPathField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { updateFindScriptButton.accept(null); } @Override public void insertUpdate(DocumentEvent e) { updateFindScriptButton.accept(null); } @Override public void changedUpdate(DocumentEvent e) { updateFindScriptButton.accept(null); } }); updateFindScriptButton.accept(null); add(scriptPathBox, BorderLayout.NORTH); if (component != null) { add(component, BorderLayout.CENTER); } }
From source file:com.diversityarrays.kdxplore.heatmap.HeatMapParamsDialog.java
public HeatMapParamsDialog(VisualisationTool vtool, CurationContext ctx, // PlotInfoProvider pip, SelectedValueStore svs, Map<TraitInstance, SimpleStatistics<?>> numericStatsByTraitInstance, Map<JFrame, HeatMapPanelParameters> heatMapPanelParamsByFrame, VisToolOpenClose vtoc, SuppressionHandler suppressionHandler) { super(ctx.getDialogOwnerWindow(), Msg.TOOLNAME_HEATMAP(), ModalityType.MODELESS); this.suppressionHandler = suppressionHandler; this.visualisationTool = vtool; this.context = ctx; this.selectedValueStore = svs; // this.plotInfoProvider = pip; this.heatMapPanelParamsByFrame = heatMapPanelParamsByFrame; this.visToolOpenClose = vtoc; // this.heatMapFrameByPane = new HashMap<JFrame, HeatMapPane>(); List<ValueRetriever<?>> positionAndPlotRetrievers = new ArrayList<>(); Trial trial = context.getTrial();/*from www . j ava 2 s .c o m*/ positionAndPlotRetrievers.addAll(ValueRetrieverFactory.getPlotIdentValueRetrievers(trial)); Map<PlotAttribute, Set<String>> attributesAndValues = context.getPlotAttributesAndValues(); for (PlotAttribute pa : attributesAndValues.keySet()) { positionAndPlotRetrievers.add(new PlotAttributeValueRetriever(pa, attributesAndValues.get(pa))); } pnatPanel = new AskForPositionNamesAndTraitInstancePanel(2, // positionNames 1, // traitInstances positionAndPlotRetrievers, numericStatsByTraitInstance, enableActionNotifier, context); createHeatMapAction.setEnabled(false); Box buttons = Box.createHorizontalBox(); buttons.add(Box.createHorizontalGlue()); buttons.add(new JButton(createHeatMapAction)); getContentPane().add(pnatPanel, BorderLayout.CENTER); getContentPane().add(buttons, BorderLayout.SOUTH); pack(); }
From source file:edu.gmu.cs.sim.util.media.chart.XYChartGenerator.java
protected void buildGlobalAttributes(LabelledList list) { // create the chart ((XYPlot) (chart.getPlot())).setDomainGridlinesVisible(false); ((XYPlot) (chart.getPlot())).setRangeGridlinesVisible(false); ((XYPlot) (chart.getPlot())).setDomainGridlinePaint(new Color(200, 200, 200)); ((XYPlot) (chart.getPlot())).setRangeGridlinePaint(new Color(200, 200, 200)); xLabel = new PropertyField() { public String newValue(String newValue) { setXAxisLabel(newValue);/* w w w . j a v a 2 s.co m*/ getChartPanel().repaint(); return newValue; } }; xLabel.setValue(getXAxisLabel()); list.add(new JLabel("X Label"), xLabel); yLabel = new PropertyField() { public String newValue(String newValue) { setYAxisLabel(newValue); getChartPanel().repaint(); return newValue; } }; yLabel.setValue(getYAxisLabel()); list.add(new JLabel("Y Label"), yLabel); xLog = new JCheckBox(); xLog.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (xLog.isSelected()) { LogarithmicAxis logAxis = new LogarithmicAxis(xLabel.getValue()); logAxis.setStrictValuesFlag(false); chart.getXYPlot().setDomainAxis(logAxis); } else { chart.getXYPlot().setDomainAxis(new NumberAxis(xLabel.getValue())); } } }); yLog = new JCheckBox(); yLog.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (yLog.isSelected()) { LogarithmicAxis logAxis = new LogarithmicAxis(yLabel.getValue()); logAxis.setStrictValuesFlag(false); chart.getXYPlot().setRangeAxis(logAxis); } else { chart.getXYPlot().setRangeAxis(new NumberAxis(yLabel.getValue())); } } }); Box box = Box.createHorizontalBox(); box.add(new JLabel("X")); box.add(xLog); box.add(new JLabel(" Y")); box.add(yLog); box.add(Box.createGlue()); list.add(new JLabel("Log Axis"), box); final JCheckBox xgridlines = new JCheckBox(); xgridlines.setSelected(false); ItemListener il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { chart.getXYPlot().setDomainGridlinesVisible(true); } else { chart.getXYPlot().setDomainGridlinesVisible(false); } } }; xgridlines.addItemListener(il); final JCheckBox ygridlines = new JCheckBox(); ygridlines.setSelected(false); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { chart.getXYPlot().setRangeGridlinesVisible(true); } else { chart.getXYPlot().setRangeGridlinesVisible(false); } } }; ygridlines.addItemListener(il); box = Box.createHorizontalBox(); box.add(new JLabel("X")); box.add(xgridlines); box.add(new JLabel(" Y")); box.add(ygridlines); box.add(Box.createGlue()); list.add(new JLabel("Grid Lines"), box); }
From source file:sim.util.media.chart.XYChartGenerator.java
protected void buildGlobalAttributes(LabelledList list) { // create the chart ((XYPlot) (chart.getPlot())).setDomainGridlinesVisible(false); ((XYPlot) (chart.getPlot())).setRangeGridlinesVisible(false); ((XYPlot) (chart.getPlot())).setDomainGridlinePaint(new Color(200, 200, 200)); ((XYPlot) (chart.getPlot())).setRangeGridlinePaint(new Color(200, 200, 200)); xLabel = new PropertyField() { public String newValue(String newValue) { setXAxisLabel(newValue);//w w w . java2 s. co m getChartPanel().repaint(); return newValue; } }; xLabel.setValue(getXAxisLabel()); list.add(new JLabel("X Label"), xLabel); yLabel = new PropertyField() { public String newValue(String newValue) { setYAxisLabel(newValue); getChartPanel().repaint(); return newValue; } }; yLabel.setValue(getYAxisLabel()); list.add(new JLabel("Y Label"), yLabel); xLog = new JCheckBox(); xLog.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (xLog.isSelected()) { LogarithmicAxis logAxis = new LogarithmicAxis(xLabel.getValue()); logAxis.setStrictValuesFlag(false); chart.getXYPlot().setDomainAxis(logAxis); } else chart.getXYPlot().setDomainAxis(new NumberAxis(xLabel.getValue())); } }); yLog = new JCheckBox(); yLog.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (yLog.isSelected()) { LogarithmicAxis logAxis = new LogarithmicAxis(yLabel.getValue()); logAxis.setStrictValuesFlag(false); chart.getXYPlot().setRangeAxis(logAxis); } else chart.getXYPlot().setRangeAxis(new NumberAxis(yLabel.getValue())); } }); Box box = Box.createHorizontalBox(); box.add(new JLabel("X")); box.add(xLog); box.add(new JLabel(" Y")); box.add(yLog); box.add(Box.createGlue()); list.add(new JLabel("Log Axis"), box); final JCheckBox xgridlines = new JCheckBox(); xgridlines.setSelected(false); ItemListener il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { chart.getXYPlot().setDomainGridlinesVisible(true); } else { chart.getXYPlot().setDomainGridlinesVisible(false); } } }; xgridlines.addItemListener(il); final JCheckBox ygridlines = new JCheckBox(); ygridlines.setSelected(false); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { chart.getXYPlot().setRangeGridlinesVisible(true); } else { chart.getXYPlot().setRangeGridlinesVisible(false); } } }; ygridlines.addItemListener(il); box = Box.createHorizontalBox(); box.add(new JLabel("X")); box.add(xgridlines); box.add(new JLabel(" Y")); box.add(ygridlines); box.add(Box.createGlue()); list.add(new JLabel("Grid Lines"), box); }
From source file:com.diversityarrays.kdxplore.field.TrialLayoutEditorDialog.java
public TrialLayoutEditorDialog(Window owner, String title) { super(owner, title, ModalityType.APPLICATION_MODAL); setDefaultCloseOperation(DISPOSE_ON_CLOSE); trialLayoutEditPanel = new TrialLayoutEditPanel(onLayoutComplete); saveAction.setEnabled(false);//from ww w . ja v a 2 s.co m Box buttons = Box.createHorizontalBox(); buttons.add(new JButton(cancelAction)); buttons.add(new JButton(saveAction)); Container cp = getContentPane(); cp.add(trialLayoutEditPanel, BorderLayout.CENTER); cp.add(buttons, BorderLayout.SOUTH); pack(); }