List of usage examples for javax.swing JDialog setLayout
public void setLayout(LayoutManager manager)
From source file:org.fhcrc.cpl.viewer.ms2.Fractionation2DUtilities.java
public static void showHeatMapChart(FractionatedAMTDatabaseStructure amtDatabaseStructure, double[] dataForChart, String chartName, boolean showLegend) { int chartWidth = 1000; int chartHeight = 1000; double globalMinValue = Double.MAX_VALUE; double globalMaxValue = Double.MIN_VALUE; for (double value : dataForChart) { if (value < globalMinValue) globalMinValue = value;//from w w w . j av a 2s.c om if (value > globalMaxValue) globalMaxValue = value; } _log.debug("showHeatMapChart: experiment structures:"); List<double[][]> amtPeptidesInExperiments = new ArrayList<double[][]>(); for (int i = 0; i < amtDatabaseStructure.getNumExperiments(); i++) { int experimentWidth = amtDatabaseStructure.getExperimentStructure(i).columns; int experimentHeight = amtDatabaseStructure.getExperimentStructure(i).rows; _log.debug("\t" + amtDatabaseStructure.getExperimentStructure(i)); amtPeptidesInExperiments.add(new double[experimentWidth][experimentHeight]); } for (int i = 0; i < dataForChart.length; i++) { Pair<Integer, int[]> positionInExperiments = amtDatabaseStructure.calculateExperimentAndPosition(i); int xpos = positionInExperiments.second[0]; int ypos = positionInExperiments.second[1]; int experimentIndex = positionInExperiments.first; //System.err.println("i, xpos, ypos: " + i + ", " + xpos + ", " + ypos); amtPeptidesInExperiments.get(experimentIndex)[xpos][ypos] = dataForChart[i]; } JDialog cd = new JDialog(ApplicationContext.getFrame(), "Heat Map(s)"); cd.setSize(chartWidth, chartHeight); cd.setPreferredSize(new Dimension(chartWidth, chartHeight)); cd.setLayout(new FlowLayout()); int nextPerfectSquareRoot = 0; while (true) { nextPerfectSquareRoot++; if ((nextPerfectSquareRoot * nextPerfectSquareRoot) >= amtPeptidesInExperiments.size()) { break; } } int plotWidth = (int) ((double) (chartWidth - 20) / (double) nextPerfectSquareRoot); int plotHeight = (int) ((double) (chartHeight - 20) / (double) nextPerfectSquareRoot); _log.debug("Rescaled chart dimensions: " + plotWidth + "x" + plotHeight); LookupPaintScale paintScale = PanelWithHeatMap.createPaintScale(globalMinValue, globalMaxValue, Color.BLUE, Color.RED); for (int i = 0; i < amtPeptidesInExperiments.size(); i++) { PanelWithHeatMap pwhm = new PanelWithHeatMap(amtPeptidesInExperiments.get(i), "Experiment " + (i + 1)); // pwhm.setPalette(PanelWithHeatMap.PALETTE_BLUE_RED); pwhm.setPaintScale(paintScale); pwhm.setPreferredSize(new Dimension(plotWidth, plotHeight)); pwhm.setAxisLabels("AX Fraction", "RP Fraction"); if (!showLegend) pwhm.getChart().removeLegend(); cd.add(pwhm); } cd.setTitle(chartName); cd.setVisible(true); }
From source file:org.pgptool.gui.ui.importkey.KeyImporterView.java
@Override protected JDialog initDialog(Window owner, Object constraints) { JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL); ret.setLayout(new BorderLayout()); ret.setResizable(true);//ww w . ja va 2 s .c o m ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); ret.setTitle(Messages.get("action.importKey")); ret.add(pnl, BorderLayout.CENTER); ret.setMinimumSize(new Dimension(spacing(60), spacing(30))); initWindowGeometryPersister(ret, "keyImprt"); return ret; }
From source file:org.pgptool.gui.ui.keyslist.KeysListView.java
@Override protected JDialog initDialog(Window owner, Object constraints) { JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL); ret.setMinimumSize(new Dimension(spacing(50), spacing(25))); ret.setLayout(new BorderLayout()); ret.setResizable(true);/*from w ww .ja v a 2 s . c o m*/ ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); ret.setTitle(Messages.get("term.keysList")); ret.add(panelRoot, BorderLayout.CENTER); ret.setJMenuBar(menuBar); initWindowGeometryPersister(ret, "keysList"); return ret; }
From source file:net.phyloviz.project.action.LoadDataSetAction.java
private JDialog createLoadingDialog() { JDialog d = new JDialog(WindowManager.getDefault().getMainWindow(), null, true); d.setLayout(new GridBagLayout()); JPanel panel = new JPanel(); JLabel jlabel = new JLabel("Loading DataSet....."); jlabel.setFont(new Font("Verdana", 1, 14)); panel.add(jlabel);//w w w . j av a 2 s .c o m d.add(panel, new GridBagConstraints()); d.setSize(200, 50); d.setLocationRelativeTo(null); d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); return d; }
From source file:userinterface.graph.Histogram.java
/** * Generates the property dialog for a Histogram. Allows the user to select either a new or an exisitng Histogram * to plot data on/* w w w. j a v a 2 s . com*/ * * @param defaultSeriesName * @param handler instance of {@link GUIGraphHandler} * @param minVal the min value in data cache * @param maxVal the max value in data cache * @return Either a new instance of a Histogram or an old one depending on what the user selects */ public static Pair<Histogram, SeriesKey> showPropertiesDialog(String defaultSeriesName, GUIGraphHandler handler, double minVal, double maxVal) { // make sure that the probabilities are valid if (maxVal > 1.0) maxVal = 1.0; if (minVal < 0.0) minVal = 0.0; // set properties for the dialog JDialog dialog = new JDialog(GUIPrism.getGUI(), "Histogram properties", true); dialog.setLayout(new BorderLayout()); JPanel p1 = new JPanel(new FlowLayout()); p1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Number of buckets")); JPanel p2 = new JPanel(new FlowLayout()); p2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Series name")); JSpinner buckets = new JSpinner(new SpinnerNumberModel(10, 5, Integer.MAX_VALUE, 1)); buckets.setToolTipText("Select the number of buckets for this Histogram"); // provides the ability to select a new or an old histogram to plot the series on JTextField seriesName = new JTextField(defaultSeriesName); JRadioButton newSeries = new JRadioButton("New Histogram"); JRadioButton existing = new JRadioButton("Existing Histogram"); newSeries.setSelected(true); JPanel seriesSelectPanel = new JPanel(); seriesSelectPanel.setLayout(new BoxLayout(seriesSelectPanel, BoxLayout.Y_AXIS)); JPanel seriesTypeSelect = new JPanel(new FlowLayout()); JPanel seriesOptionsPanel = new JPanel(new FlowLayout()); seriesTypeSelect.add(newSeries); seriesTypeSelect.add(existing); JComboBox<String> seriesOptions = new JComboBox<>(); seriesOptionsPanel.add(seriesOptions); seriesSelectPanel.add(seriesTypeSelect); seriesSelectPanel.add(seriesOptionsPanel); seriesSelectPanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Add series to")); // provides ability to select the min/max range of the plot JLabel minValsLabel = new JLabel("Min range:"); JSpinner minVals = new JSpinner(new SpinnerNumberModel(0.0, 0.0, minVal, 0.01)); minVals.setToolTipText("Does not allow value more than the min value in the probabilities"); JLabel maxValsLabel = new JLabel("Max range:"); JSpinner maxVals = new JSpinner(new SpinnerNumberModel(1.0, maxVal, 1.0, 0.01)); maxVals.setToolTipText("Does not allow value less than the max value in the probabilities"); JPanel minMaxPanel = new JPanel(); minMaxPanel.setLayout(new BoxLayout(minMaxPanel, BoxLayout.X_AXIS)); JPanel leftValsPanel = new JPanel(new BorderLayout()); JPanel rightValsPanel = new JPanel(new BorderLayout()); minMaxPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Range")); leftValsPanel.add(minValsLabel, BorderLayout.WEST); leftValsPanel.add(minVals, BorderLayout.CENTER); rightValsPanel.add(maxValsLabel, BorderLayout.WEST); rightValsPanel.add(maxVals, BorderLayout.CENTER); minMaxPanel.add(leftValsPanel); minMaxPanel.add(rightValsPanel); // fill the old histograms in the property dialog boolean found = false; for (int i = 0; i < handler.getNumModels(); i++) { if (handler.getModel(i) instanceof Histogram) { seriesOptions.addItem(handler.getGraphName(i)); found = true; } } existing.setEnabled(found); seriesOptions.setEnabled(false); // the bottom panel JPanel options = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton ok = new JButton("Plot"); JButton cancel = new JButton("Cancel"); // bind keyboard keys to plot and cancel buttons to improve usability ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok"); ok.getActionMap().put("ok", new AbstractAction() { private static final long serialVersionUID = -7324877661936685228L; @Override public void actionPerformed(ActionEvent e) { ok.doClick(); } }); cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "ok"); cancel.getActionMap().put("ok", new AbstractAction() { private static final long serialVersionUID = 2642213543774356676L; @Override public void actionPerformed(ActionEvent e) { cancel.doClick(); } }); //Action listener for the new series radio button newSeries.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (newSeries.isSelected()) { existing.setSelected(false); seriesOptions.setEnabled(false); buckets.setEnabled(true); buckets.setToolTipText("Select the number of buckets for this Histogram"); minVals.setEnabled(true); maxVals.setEnabled(true); } } }); //Action listener for the existing series radio button existing.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (existing.isSelected()) { newSeries.setSelected(false); seriesOptions.setEnabled(true); buckets.setEnabled(false); minVals.setEnabled(false); maxVals.setEnabled(false); buckets.setToolTipText("Number of buckets can't be changed on an existing Histogram"); } } }); //Action listener for the plot button ok.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); if (newSeries.isSelected()) { hist = new Histogram(); hist.setNumOfBuckets((int) buckets.getValue()); hist.setIsNew(true); } else if (existing.isSelected()) { String HistName = (String) seriesOptions.getSelectedItem(); hist = (Histogram) handler.getModel(HistName); hist.setIsNew(false); } key = hist.addSeries(seriesName.getText()); if (minVals.isEnabled() && maxVals.isEnabled()) { hist.setMinProb((double) minVals.getValue()); hist.setMaxProb((double) maxVals.getValue()); } } }); //Action listener for the cancel button cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); hist = null; } }); dialog.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { hist = null; } }); p1.add(buckets, BorderLayout.CENTER); p2.add(seriesName, BorderLayout.CENTER); options.add(ok); options.add(cancel); // add everything to the main panel of the dialog JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.add(seriesSelectPanel); mainPanel.add(p1); mainPanel.add(p2); mainPanel.add(minMaxPanel); // add main panel to the dialog dialog.add(mainPanel, BorderLayout.CENTER); dialog.add(options, BorderLayout.SOUTH); // set dialog properties dialog.setSize(320, 290); dialog.setLocationRelativeTo(GUIPrism.getGUI()); dialog.setVisible(true); // return the user selected Histogram with the properties set return new Pair<Histogram, SeriesKey>(hist, key); }
From source file:es.emergya.ui.base.Message.java
private void inicializar(final String texto) { log.trace("inicializar(" + texto + ")"); final Message message_ = this; SwingUtilities.invokeLater(new Runnable() { @Override/*from w w w. j a va 2 s . c om*/ public void run() { log.trace("Sacamos un nuevo mensaje: " + texto); JDialog frame = new JDialog(window.getFrame(), true); frame.setUndecorated(true); frame.getContentPane().setBackground(Color.WHITE); frame.setLocation(150, window.getHeight() - 140); frame.setSize(new Dimension(window.getWidth() - 160, 130)); frame.setName("Incoming Message"); frame.setBackground(Color.WHITE); frame.getRootPane().setBorder(new MatteBorder(4, 4, 4, 4, color)); frame.setLayout(new BorderLayout()); if (font != null) frame.setFont(font); JLabel icon = new JLabel(new ImageIcon(this.getClass().getResource("/images/button-ok.png"))); icon.setToolTipText("Cerrar"); icon.removeMouseListener(null); icon.addMouseListener(new Cerrar(frame, message_)); JLabel text = new JLabel(texto); text.setBackground(Color.WHITE); text.setForeground(Color.BLACK); frame.add(text, BorderLayout.WEST); frame.add(icon, BorderLayout.EAST); frame.setVisible(true); } }); }
From source file:com.net2plan.gui.GUINet2Plan.java
private void showKeyCombinations() { Component component = container.getComponent(0); if (!(component instanceof IGUIModule)) { ErrorHandling.showErrorDialog("No tool is active", "Unable to show key associations"); return;//from w w w . ja v a 2 s .c o m } final JDialog dialog = new JDialog(); dialog.setTitle("Key combinations"); SwingUtils.configureCloseDialogOnEscape(dialog); dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); dialog.setSize(new Dimension(500, 300)); dialog.setLocationRelativeTo(null); dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); dialog.setLayout(new MigLayout("fill, insets 0 0 0 0")); final String[] tableHeader = StringUtils.arrayOf("Key combination", "Action"); DefaultTableModel model = new ClassAwareTableModel(); model.setDataVector(new Object[1][tableHeader.length], tableHeader); AdvancedJTable table = new AdvancedJTable(model); JScrollPane scrollPane = new JScrollPane(table); dialog.add(scrollPane, "grow"); RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model); table.setRowSorter(sorter); table.getTableHeader().addMouseListener(new ColumnFitAdapter()); IGUIModule module = (IGUIModule) component; Map<String, KeyStroke> keyCombinations = module.getKeyCombinations(); if (!keyCombinations.isEmpty()) { model.removeRow(0); for (Entry<String, KeyStroke> keyCombination : keyCombinations.entrySet()) { String description = keyCombination.getKey(); KeyStroke keyStroke = keyCombination.getValue(); model.addRow(StringUtils.arrayOf(description, keyStroke.toString().replaceAll(" pressed ", " "))); } } dialog.setVisible(true); }
From source file:com.net2plan.gui.utils.onlineSimulationPane.OnlineSimulationPane.java
/** * Shows the future event list./* w w w. j a v a2s . co m*/ * * @since 0.3.0 */ public void viewFutureEventList() { final JDialog dialog = new JDialog(); dialog.setTitle("Future event list"); SwingUtils.configureCloseDialogOnEscape(dialog); dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); dialog.setSize(new Dimension(500, 300)); dialog.setLocationRelativeTo(null); dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); dialog.setLayout(new MigLayout("fill, insets 0 0 0 0")); final String[] tableHeader = StringUtils.arrayOf("Id", "Time", "Priority", "Type", "To module", "Custom object"); Object[][] data = new Object[1][tableHeader.length]; DefaultTableModel model = new ClassAwareTableModel(); model.setDataVector(new Object[1][tableHeader.length], tableHeader); JTable table = new AdvancedJTable(model); RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model); table.setRowSorter(sorter); JScrollPane scrollPane = new JScrollPane(table); dialog.add(scrollPane, "grow"); PriorityQueue<SimEvent> futureEventList = simKernel.getSimCore().getFutureEventList().getPendingEvents(); if (!futureEventList.isEmpty()) { int numEvents = futureEventList.size(); SimEvent[] futureEventList_array = futureEventList.toArray(new SimEvent[numEvents]); Arrays.sort(futureEventList_array, futureEventList.comparator()); data = new Object[numEvents][tableHeader.length]; for (int eventId = 0; eventId < numEvents; eventId++) { // List<SimAction> actions = futureEventList_array[eventId].getEventActionList(); Object customObject = futureEventList_array[eventId].getEventObject(); data[eventId][0] = eventId; data[eventId][1] = StringUtils .secondsToYearsDaysHoursMinutesSeconds(futureEventList_array[eventId].getEventTime()); data[eventId][2] = futureEventList_array[eventId].getEventPriority(); data[eventId][3] = futureEventList_array[eventId].getEventType(); data[eventId][4] = futureEventList_array[eventId].getEventDestinationModule().toString(); data[eventId][5] = customObject == null ? "none" : customObject; } } model.setDataVector(data, tableHeader); table.getTableHeader().addMouseListener(new ColumnFitAdapter()); table.setDefaultRenderer(Double.class, new CellRenderers.NumberCellRenderer()); dialog.setVisible(true); }
From source file:edu.umich.robot.GuiApplication.java
/** * <p>/* w w w . j a v a2 s. co m*/ * Pops up a window to create a new splinter robot to add to the simulation. */ public void createSplinterRobotDialog() { final Pose pose = new Pose(); FormLayout layout = new FormLayout("right:pref, 4dlu, 30dlu, 4dlu, right:pref, 4dlu, 30dlu", "pref, 2dlu, pref, 2dlu, pref"); layout.setRowGroups(new int[][] { { 1, 3 } }); final JDialog dialog = new JDialog(frame, "Create Splinter Robot", true); dialog.setLayout(layout); final JTextField name = new JTextField(); final JTextField x = new JTextField(Double.toString((pose.getX()))); final JTextField y = new JTextField(Double.toString((pose.getY()))); final JButton cancel = new JButton("Cancel"); final JButton ok = new JButton("OK"); CellConstraints cc = new CellConstraints(); dialog.add(new JLabel("Name"), cc.xy(1, 1)); dialog.add(name, cc.xyw(3, 1, 5)); dialog.add(new JLabel("x"), cc.xy(1, 3)); dialog.add(x, cc.xy(3, 3)); dialog.add(new JLabel("y"), cc.xy(5, 3)); dialog.add(y, cc.xy(7, 3)); dialog.add(cancel, cc.xyw(1, 5, 3)); dialog.add(ok, cc.xyw(5, 5, 3)); x.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { try { pose.setX(Double.parseDouble(x.getText())); } catch (NumberFormatException ex) { x.setText(Double.toString(pose.getX())); } } }); y.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { try { pose.setY(Double.parseDouble(y.getText())); } catch (NumberFormatException ex) { y.setText(Double.toString(pose.getX())); } } }); final ActionListener okListener = new ActionListener() { public void actionPerformed(ActionEvent e) { String robotName = name.getText().trim(); if (robotName.isEmpty()) { logger.error("Create splinter: robot name empty"); return; } for (char c : robotName.toCharArray()) if (!Character.isDigit(c) && !Character.isLetter(c)) { logger.error("Create splinter: illegal robot name"); return; } controller.createSplinterRobot(robotName, pose, true); controller.createSimSplinter(robotName); controller.createSimLaser(robotName); dialog.dispose(); } }; name.addActionListener(okListener); x.addActionListener(okListener); y.addActionListener(okListener); ok.addActionListener(okListener); ActionListener cancelAction = new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.dispose(); } }; cancel.addActionListener(cancelAction); dialog.getRootPane().registerKeyboardAction(cancelAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); dialog.setLocationRelativeTo(frame); dialog.pack(); dialog.setVisible(true); }
From source file:edu.umich.robot.GuiApplication.java
public void createSuperdroidRobotDialog() { final Pose pose = new Pose(); FormLayout layout = new FormLayout("right:pref, 4dlu, 30dlu, 4dlu, right:pref, 4dlu, 30dlu", "pref, 2dlu, pref, 2dlu, pref"); layout.setRowGroups(new int[][] { { 1, 3 } }); final JDialog dialog = new JDialog(frame, "Create Superdroid Robot", true); dialog.setLayout(layout); final JTextField name = new JTextField(); final JTextField x = new JTextField(Double.toString((pose.getX()))); final JTextField y = new JTextField(Double.toString((pose.getY()))); final JButton cancel = new JButton("Cancel"); final JButton ok = new JButton("OK"); CellConstraints cc = new CellConstraints(); dialog.add(new JLabel("Name"), cc.xy(1, 1)); dialog.add(name, cc.xyw(3, 1, 5));/* w w w.ja v a2s . c o m*/ dialog.add(new JLabel("x"), cc.xy(1, 3)); dialog.add(x, cc.xy(3, 3)); dialog.add(new JLabel("y"), cc.xy(5, 3)); dialog.add(y, cc.xy(7, 3)); dialog.add(cancel, cc.xyw(1, 5, 3)); dialog.add(ok, cc.xyw(5, 5, 3)); x.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { try { pose.setX(Double.parseDouble(x.getText())); } catch (NumberFormatException ex) { x.setText(Double.toString(pose.getX())); } } }); y.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { try { pose.setY(Double.parseDouble(y.getText())); } catch (NumberFormatException ex) { y.setText(Double.toString(pose.getX())); } } }); final ActionListener okListener = new ActionListener() { public void actionPerformed(ActionEvent e) { String robotName = name.getText().trim(); if (robotName.isEmpty()) { logger.error("Create Superdroid: robot name empty"); return; } for (char c : robotName.toCharArray()) if (!Character.isDigit(c) && !Character.isLetter(c)) { logger.error("Create Superdroid: illegal robot name"); return; } controller.createSuperdroidRobot(robotName, pose, true); controller.createSimSuperdroid(robotName); dialog.dispose(); } }; name.addActionListener(okListener); x.addActionListener(okListener); y.addActionListener(okListener); ok.addActionListener(okListener); ActionListener cancelAction = new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.dispose(); } }; cancel.addActionListener(cancelAction); dialog.getRootPane().registerKeyboardAction(cancelAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); dialog.setLocationRelativeTo(frame); dialog.pack(); dialog.setVisible(true); }