List of usage examples for javax.swing JDialog setPreferredSize
public void setPreferredSize(Dimension preferredSize)
From source file:org.matsim.contrib.util.chart.ChartWindowUtils.java
public static void showDialog(JFreeChart chart, String title, int width, int height, boolean modal) { JDialog dialog = newChartDialog(chart, title, modal); dialog.setPreferredSize(new Dimension(width, height)); SwingUtils.showWindow(dialog, modal); }
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 ava2 s. co m 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:com.digitalgeneralists.assurance.ui.components.ComparisonResultPanel.java
private void displayAttributesDialog(FileReference file) { ClassPathXmlApplicationContext springContext = null; try {/*w w w .ja v a2 s . c o m*/ if (this.getParent() != null) { JFrame parent = (JFrame) SwingUtilities.getWindowAncestor(this.getParent()); springContext = new ClassPathXmlApplicationContext("/META-INF/spring/app-context.xml"); IDialogFactory dialogFactory = (IDialogFactory) springContext.getBean("DialogFactory"); JDialog scanDefinitionDialog = dialogFactory.createFileAttributesDialogInstance(parent, ModalityType.APPLICATION_MODAL, file); scanDefinitionDialog.setPreferredSize(new Dimension(400, 600)); scanDefinitionDialog.setVisible(true); dialogFactory = null; } } finally { if (springContext != null) { springContext.close(); springContext = null; } } }
From source file:org.moeaframework.analysis.plot.Plot.java
/** * Displays the chart in a blocking JDialog. * /*from ww w. j a va2 s . c o m*/ * @param width the width of the chart * @param height the height of the chart * @return the window that was created */ public JDialog showDialog(int width, int height) { JDialog frame = new JDialog(); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(getChartPanel(), BorderLayout.CENTER); frame.setPreferredSize(new Dimension(width, height)); frame.pack(); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setTitle("MOEA Framework Plot"); frame.setModalityType(ModalityType.APPLICATION_MODAL); frame.setVisible(true); return frame; }
From source file:eu.apenet.dpt.standalone.gui.DataPreparationToolGUI.java
private void wireUp() { fileItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { if (actionEvent.getSource() == fileItem) { currentLocation = new File(retrieveFromDb.retrieveOpenLocation()); fileChooser.setCurrentDirectory(currentLocation); int returnedVal = fileChooser.showOpenDialog(getParent()); if (returnedVal == JFileChooser.APPROVE_OPTION) { currentLocation = fileChooser.getCurrentDirectory(); retrieveFromDb.saveOpenLocation(currentLocation.getAbsolutePath()); RootPaneContainer root = (RootPaneContainer) getRootPane().getTopLevelAncestor(); root.getGlassPane().setCursor(WAIT_CURSOR); root.getGlassPane().setVisible(true); File[] files = fileChooser.getSelectedFiles(); for (File file : files) { if (file.isDirectory()) { File[] fileArray = file.listFiles(); Arrays.sort(fileArray, new FileNameComparator()); for (File children : fileArray) { if (isCorrect(children)) { xmlEadListModel.addFile(children); }/*w w w. j ava 2 s.c o m*/ } } else { if (isCorrect(file)) { xmlEadListModel.addFile(file); } } } root.getGlassPane().setCursor(DEFAULT_CURSOR); root.getGlassPane().setVisible(false); } } } }); repositoryCodeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { createOptionPaneForRepositoryCode(); } }); countryCodeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { createOptionPaneForCountryCode(); } }); checksLoadingFilesItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { createOptionPaneForChecksLoadingFiles(); } }); createEag2012FromExistingEag2012.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser eagFileChooser = new JFileChooser(); eagFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); eagFileChooser.setMultiSelectionEnabled(false); eagFileChooser.setCurrentDirectory(new File(retrieveFromDb.retrieveOpenLocation())); if (eagFileChooser.showOpenDialog(getParent()) == JFileChooser.APPROVE_OPTION) { currentLocation = eagFileChooser.getCurrentDirectory(); retrieveFromDb.saveOpenLocation(currentLocation.getAbsolutePath()); File eagFile = eagFileChooser.getSelectedFile(); if (!Eag2012Frame.isUsed()) { try { if (ReadXml.isXmlFile(eagFile, "eag")) { new Eag2012Frame(eagFile, getContentPane().getSize(), (ProfileListModel) getXmlEadList().getModel(), labels); } else { JOptionPane.showMessageDialog(rootPane, labels.getString("eag2012.errors.notAnEagFile")); } } catch (SAXException ex) { if (ex instanceof SAXParseException) { JOptionPane.showMessageDialog(rootPane, labels.getString("eag2012.errors.notAnEagFile")); } java.util.logging.Logger.getLogger(DataPreparationToolGUI.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (IOException ex) { java.util.logging.Logger.getLogger(DataPreparationToolGUI.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (ParserConfigurationException ex) { java.util.logging.Logger.getLogger(DataPreparationToolGUI.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (Exception ex) { try { JOptionPane.showMessageDialog(rootPane, labels.getString(ex.getMessage())); } catch (Exception ex1) { JOptionPane.showMessageDialog(rootPane, "Error..."); } } } } } }); createEag2012FromScratch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!Eag2012Frame.isUsed()) { new Eag2012Frame(getContentPane().getSize(), (ProfileListModel) getXmlEadList().getModel(), labels, retrieveFromDb.retrieveCountryCode(), retrieveFromDb.retrieveRepositoryCode()); } } }); digitalObjectTypeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!DigitalObjectAndRightsOptionFrame.isInUse()) { JFrame DigitalObjectAndRightsOptionFrame = new DigitalObjectAndRightsOptionFrame(labels, retrieveFromDb); DigitalObjectAndRightsOptionFrame.setPreferredSize(new Dimension( getContentPane().getWidth() * 3 / 8, getContentPane().getHeight() * 3 / 4)); DigitalObjectAndRightsOptionFrame.setLocation(getContentPane().getWidth() / 8, getContentPane().getHeight() / 8); DigitalObjectAndRightsOptionFrame.pack(); DigitalObjectAndRightsOptionFrame.setVisible(true); } } }); defaultSaveFolderItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { JFileChooser defaultSaveFolderChooser = new JFileChooser(); defaultSaveFolderChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); defaultSaveFolderChooser.setMultiSelectionEnabled(false); defaultSaveFolderChooser.setCurrentDirectory(new File(retrieveFromDb.retrieveDefaultSaveFolder())); if (defaultSaveFolderChooser.showOpenDialog(getParent()) == JFileChooser.APPROVE_OPTION) { File directory = defaultSaveFolderChooser.getSelectedFile(); if (directory.canWrite() && DirectoryPermission.canWrite(directory)) { retrieveFromDb.saveDefaultSaveFolder(directory + "/"); } else { createErrorOrWarningPanel(new Exception(labels.getString("error.directory.nowrites")), false, labels.getString("error.directory.nowrites"), getContentPane()); } } } }); listDateConversionRulesItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { JDialog dateConversionRulesDialog = new DateConversionRulesDialog(labels, retrieveFromDb); dateConversionRulesDialog.setPreferredSize( new Dimension(getContentPane().getWidth() * 3 / 8, getContentPane().getHeight() * 7 / 8)); dateConversionRulesDialog.setLocation(getContentPane().getWidth() / 8, getContentPane().getHeight() / 8); dateConversionRulesDialog.pack(); dateConversionRulesDialog.setVisible(true); } }); edmGeneralOptionsItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!EdmGeneralOptionsFrame.isInUse()) { JFrame edmGeneralOptionsFrame = new EdmGeneralOptionsFrame(labels, retrieveFromDb); edmGeneralOptionsFrame.setPreferredSize(new Dimension(getContentPane().getWidth() * 3 / 8, getContentPane().getHeight() * 3 / 8)); edmGeneralOptionsFrame.setLocation(getContentPane().getWidth() / 8, getContentPane().getHeight() / 8); edmGeneralOptionsFrame.pack(); edmGeneralOptionsFrame.setVisible(true); } } }); closeSelectedItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { xmlEadListModel.removeFiles(xmlEadList.getSelectedValues()); } }); saveSelectedItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String defaultOutputDirectory = retrieveFromDb.retrieveDefaultSaveFolder(); boolean isMultipleFiles = xmlEadList.getSelectedIndices().length > 1; RootPaneContainer root = (RootPaneContainer) getRootPane().getTopLevelAncestor(); root.getGlassPane().setCursor(WAIT_CURSOR); root.getGlassPane().setVisible(true); for (Object selectedValue : xmlEadList.getSelectedValues()) { File selectedFile = (File) selectedValue; String filename = selectedFile.getName(); FileInstance fileInstance = fileInstances.get(filename); String filePrefix = fileInstance.getFileType().getFilePrefix(); //todo: do we really need this? filename = filename.startsWith("temp_") ? filename.replace("temp_", "") : filename; filename = !filename.endsWith(".xml") ? filename + ".xml" : filename; if (!fileInstance.isValid()) { filePrefix = "NOT_" + filePrefix; } if (fileInstance.getLastOperation().equals(FileInstance.Operation.EDIT_TREE)) { TreeTableModel treeTableModel = tree.getTreeTableModel(); Document document = (Document) treeTableModel.getRoot(); try { File file2 = new File(defaultOutputDirectory + filePrefix + "_" + filename); File filetemp = new File(Utilities.TEMP_DIR + "temp_" + filename); TransformerFactory tf = TransformerFactory.newInstance(); Transformer output = tf.newTransformer(); output.setOutputProperty(javax.xml.transform.OutputKeys.INDENT, "yes"); output.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); DOMSource domSource = new DOMSource(document.getFirstChild()); output.transform(domSource, new StreamResult(filetemp)); output.transform(domSource, new StreamResult(file2)); fileInstance.setLastOperation(FileInstance.Operation.SAVE); fileInstance.setCurrentLocation(filetemp.getAbsolutePath()); } catch (Exception ex) { createErrorOrWarningPanel(ex, true, labels.getString("errorSavingTreeXML"), getContentPane()); } } else if (fileInstance.isConverted()) { try { File newFile = new File(defaultOutputDirectory + filePrefix + "_" + filename); FileUtils.copyFile(new File(fileInstance.getCurrentLocation()), newFile); fileInstance.setLastOperation(FileInstance.Operation.SAVE); // fileInstance.setCurrentLocation(newFile.getAbsolutePath()); } catch (IOException ioe) { LOG.error("Error when saving file", ioe); } } else { try { File newFile = new File(defaultOutputDirectory + filePrefix + "_" + filename); FileUtils.copyFile(selectedFile, newFile); fileInstance.setLastOperation(FileInstance.Operation.SAVE); // fileInstance.setCurrentLocation(newFile.getAbsolutePath()); } catch (IOException ioe) { LOG.error("Error when saving file", ioe); } } } root.getGlassPane().setCursor(DEFAULT_CURSOR); root.getGlassPane().setVisible(false); if (isMultipleFiles) { JOptionPane.showMessageDialog(getContentPane(), MessageFormat.format(labels.getString("filesInOutput"), defaultOutputDirectory) + ".", labels.getString("fileSaved"), JOptionPane.INFORMATION_MESSAGE, Utilities.icon); } else { JOptionPane.showMessageDialog(getContentPane(), MessageFormat.format(labels.getString("fileInOutput"), defaultOutputDirectory) + ".", labels.getString("fileSaved"), JOptionPane.INFORMATION_MESSAGE, Utilities.icon); } xmlEadList.updateUI(); } }); saveMessageReportItem.addActionListener( new MessageReportActionListener(retrieveFromDb, this, fileInstances, labels, this)); sendFilesWebDAV.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { throw new UnsupportedOperationException("Not supported yet."); } }); quitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); xsltItem.addActionListener(new XsltAdderActionListener(this, labels)); xsdItem.addActionListener(new XsdAdderActionListener(this, labels, retrieveFromDb)); if (Utilities.isDev) { databaseItem.addActionListener(new DatabaseCheckerActionListener(retrieveFromDb, getContentPane())); } xmlEadList.addMouseListener(new ListMouseAdapter(xmlEadList, xmlEadListModel, deleteFileItem, this)); xmlEadList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (xmlEadList.getSelectedValues() != null && xmlEadList.getSelectedValues().length != 0) { if (xmlEadList.getSelectedValues().length > 1) { // convertAndValidateBtn.setEnabled(true); // validateSelectionBtn.setEnabled(true); // if (isValidated(xmlEadList)) { // convertEdmSelectionBtn.setEnabled(true); // } else { // convertEdmSelectionBtn.setEnabled(false); // } // disableAllBtnAndItems(); saveMessageReportItem.setEnabled(true); changeInfoInGUI(""); } else { // convertAndValidateBtn.setEnabled(false); // validateSelectionBtn.setEnabled(false); // convertEdmSelectionBtn.setEnabled(false); changeInfoInGUI(((File) xmlEadList.getSelectedValue()).getName()); if (apePanel.getApeTabbedPane().getSelectedIndex() == APETabbedPane.TAB_EDITION) { apePanel.getApeTabbedPane() .createEditionTree(((File) xmlEadList.getSelectedValue())); if (tree != null) { FileInstance fileInstance = fileInstances .get(((File) getXmlEadList().getSelectedValue()).getName()); tree.addMouseListener(new PopupMouseListener(tree, getDataPreparationToolGUI(), getContentPane(), fileInstance)); } } disableTabFlashing(); } checkHoldingsGuideButton(); } else { // convertAndValidateBtn.setEnabled(false); // validateSelectionBtn.setEnabled(false); // convertEdmSelectionBtn.setEnabled(false); createHGBtn.setEnabled(false); analyzeControlaccessBtn.setEnabled(false); changeInfoInGUI(""); } } } private boolean isValidated(JList xmlEadList) { for (Object selectedValue : xmlEadList.getSelectedValues()) { File selectedFile = (File) selectedValue; String filename = selectedFile.getName(); FileInstance fileInstance = fileInstances.get(filename); if (!fileInstance.isValid()) { return false; } } return true; } }); summaryWindowItem.addActionListener(new TabItemActionListener(apePanel, APETabbedPane.TAB_SUMMARY)); validationWindowItem.addActionListener(new TabItemActionListener(apePanel, APETabbedPane.TAB_VALIDATION)); conversionWindowItem.addActionListener(new TabItemActionListener(apePanel, APETabbedPane.TAB_CONVERSION)); edmConversionWindowItem.addActionListener(new TabItemActionListener(apePanel, APETabbedPane.TAB_EDM)); editionWindowItem.addActionListener(new TabItemActionListener(apePanel, APETabbedPane.TAB_EDITION)); internetApexItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { BareBonesBrowserLaunch.openURL("http://www.apex-project.eu/"); } }); /** * Option Edit apeEAC-CPF file in the menu */ this.editEacCpfFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser eacFileChooser = new JFileChooser(); eacFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); eacFileChooser.setMultiSelectionEnabled(false); eacFileChooser.setCurrentDirectory(new File(retrieveFromDb.retrieveOpenLocation())); if (eacFileChooser.showOpenDialog(getParent()) == JFileChooser.APPROVE_OPTION) { currentLocation = eacFileChooser.getCurrentDirectory(); retrieveFromDb.saveOpenLocation(currentLocation.getAbsolutePath()); File eacFile = eacFileChooser.getSelectedFile(); if (!EacCpfFrame.isUsed()) { try { if (ReadXml.isXmlFile(eacFile, "eac-cpf")) { new EacCpfFrame(eacFile, true, getContentPane().getSize(), (ProfileListModel) getXmlEadList().getModel(), labels); } else { JOptionPane.showMessageDialog(rootPane, labels.getString("eaccpf.error.notAnEacCpfFile")); } } catch (SAXException ex) { if (ex instanceof SAXParseException) { JOptionPane.showMessageDialog(rootPane, labels.getString("eaccpf.error.notAnEacCpfFile")); } java.util.logging.Logger.getLogger(DataPreparationToolGUI.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (IOException ex) { java.util.logging.Logger.getLogger(DataPreparationToolGUI.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (ParserConfigurationException ex) { java.util.logging.Logger.getLogger(DataPreparationToolGUI.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (Exception ex) { try { JOptionPane.showMessageDialog(rootPane, labels.getString(ex.getMessage())); } catch (Exception ex1) { JOptionPane.showMessageDialog(rootPane, "Error..."); } } } } } }); /** * Option Create apeEAC-CPF in the menu */ this.createEacCpf.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!EacCpfFrame.isUsed()) { EacCpfFrame eacCpfFrame = new EacCpfFrame(getContentPane().getSize(), (ProfileListModel) getXmlEadList().getModel(), labels, retrieveFromDb.retrieveCountryCode(), retrieveFromDb.retrieveRepositoryCode(), null, null, null); } } }); }
From source file:de.codesourcery.jasm16.ide.ui.utils.UIUtils.java
public static void showErrorDialog(Component parent, String title, String textMessage, Throwable cause) { final String stacktrace; if (cause == null) { stacktrace = null;//from w w w.j a v a 2 s .co m } else { final ByteArrayOutputStream stackTrace = new ByteArrayOutputStream(); cause.printStackTrace(new PrintStream(stackTrace)); stacktrace = new String(stackTrace.toByteArray()); } final JDialog dialog = new JDialog((Window) null, title); dialog.setModal(true); final JTextArea message = createMultiLineLabel(textMessage); final DialogResult[] outcome = { DialogResult.CANCEL }; final JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { outcome[0] = DialogResult.YES; dialog.dispose(); } }); final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout()); buttonPanel.add(okButton); final JPanel messagePanel = new JPanel(); messagePanel.setLayout(new GridBagLayout()); GridBagConstraints cnstrs = constraints(0, 0, true, true, GridBagConstraints.BOTH); cnstrs.weightx = 1; cnstrs.weighty = 0.1; cnstrs.gridheight = 1; messagePanel.add(message, cnstrs); if (stacktrace != null) { final JTextArea createMultiLineLabel = new JTextArea(stacktrace); createMultiLineLabel.setBackground(null); createMultiLineLabel.setEditable(false); createMultiLineLabel.setBorder(null); createMultiLineLabel.setLineWrap(false); createMultiLineLabel.setWrapStyleWord(false); final JScrollPane pane = new JScrollPane(createMultiLineLabel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); cnstrs = constraints(0, 1, true, true, GridBagConstraints.BOTH); cnstrs.weightx = 1.0; cnstrs.weighty = 0.9; cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.gridheight = GridBagConstraints.REMAINDER; messagePanel.add(pane, cnstrs); } final JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, true, false, GridBagConstraints.BOTH); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.gridheight = 1; cnstrs.weighty = 1.0; cnstrs.insets = new Insets(5, 2, 5, 2); // top,left,bottom,right panel.add(messagePanel, cnstrs); cnstrs = constraints(0, 1, true, true, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.gridheight = 1; cnstrs.weighty = 0; cnstrs.insets = new Insets(0, 2, 10, 2); // top,left,bottom,right panel.add(buttonPanel, cnstrs); dialog.getContentPane().add(panel); dialog.setMinimumSize(new Dimension(600, 400)); dialog.setPreferredSize(new Dimension(600, 400)); dialog.setMaximumSize(new Dimension(600, 400)); dialog.pack(); dialog.setVisible(true); }
From source file:org.drugis.addis.gui.WelcomeDialog.java
private void showExampleInfo(String helpText) { final JDialog dialog = new JDialog(this); dialog.setLocationByPlatform(true);/* w w w . j a v a 2s.c om*/ dialog.setPreferredSize(new Dimension(500, 250)); JComponent helpPane = TextComponentFactory.createTextPane(helpText, true); JButton closeButton = new JButton("Close"); closeButton.setMnemonic('c'); closeButton.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent arg0) { dialog.dispose(); } }); JPanel panel = new JPanel(new BorderLayout()); panel.add(helpPane, BorderLayout.CENTER); panel.add(closeButton, BorderLayout.SOUTH); dialog.add(panel); dialog.pack(); dialog.setVisible(true); }