List of usage examples for javax.swing JDialog pack
@SuppressWarnings("deprecation") public void pack()
From source file:org.apache.log4j.chainsaw.LogUI.java
/** * Displays a dialog which will provide options for selecting a configuration *//*w w w . ja va 2 s . c o m*/ private void showReceiverConfigurationPanel() { SwingUtilities.invokeLater(new Runnable() { public void run() { final JDialog dialog = new JDialog(LogUI.this, true); dialog.setTitle("Load events into Chainsaw"); dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); dialog.setResizable(false); receiverConfigurationPanel.setCompletionActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.setVisible(false); if (receiverConfigurationPanel.getModel().isCancelled()) { return; } applicationPreferenceModel .setShowNoReceiverWarning(!receiverConfigurationPanel.isDontWarnMeAgain()); //remove existing plugins List plugins = pluginRegistry.getPlugins(); for (Iterator iter = plugins.iterator(); iter.hasNext();) { Plugin plugin = (Plugin) iter.next(); //don't stop ZeroConfPlugin if it is registered if (!plugin.getName().toLowerCase(Locale.ENGLISH).contains("zeroconf")) { pluginRegistry.stopPlugin(plugin.getName()); } } URL configURL = null; if (receiverConfigurationPanel.getModel().isNetworkReceiverMode()) { int port = receiverConfigurationPanel.getModel().getNetworkReceiverPort(); try { Class receiverClass = receiverConfigurationPanel.getModel() .getNetworkReceiverClass(); Receiver networkReceiver = (Receiver) receiverClass.newInstance(); networkReceiver.setName(receiverClass.getSimpleName() + "-" + port); Method portMethod = networkReceiver.getClass().getMethod("setPort", new Class[] { int.class }); portMethod.invoke(networkReceiver, new Object[] { new Integer(port) }); networkReceiver.setThreshold(Level.TRACE); pluginRegistry.addPlugin(networkReceiver); networkReceiver.activateOptions(); receiversPanel.updateReceiverTreeInDispatchThread(); } catch (Exception e3) { MessageCenter.getInstance().getLogger().error("Error creating Receiver", e3); MessageCenter.getInstance().getLogger() .info("An error occurred creating your Receiver"); } } else if (receiverConfigurationPanel.getModel().isLog4jConfig()) { File log4jConfigFile = receiverConfigurationPanel.getModel().getLog4jConfigFile(); if (log4jConfigFile != null) { try { Map entries = LogFilePatternLayoutBuilder .getAppenderConfiguration(log4jConfigFile); for (Iterator iter = entries.entrySet().iterator(); iter.hasNext();) { try { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Map values = (Map) entry.getValue(); //values: conversion, file String conversionPattern = values.get("conversion").toString(); File file = new File(values.get("file").toString()); URL fileURL = file.toURI().toURL(); String timestampFormat = LogFilePatternLayoutBuilder .getTimeStampFormat(conversionPattern); String receiverPattern = LogFilePatternLayoutBuilder .getLogFormatFromPatternLayout(conversionPattern); VFSLogFilePatternReceiver fileReceiver = new VFSLogFilePatternReceiver(); fileReceiver.setName(name); fileReceiver.setAutoReconnect(true); fileReceiver.setContainer(LogUI.this); fileReceiver.setAppendNonMatches(true); fileReceiver.setFileURL(fileURL.toURI().toString()); fileReceiver.setTailing(true); fileReceiver.setLogFormat(receiverPattern); fileReceiver.setTimestampFormat(timestampFormat); fileReceiver.setThreshold(Level.TRACE); pluginRegistry.addPlugin(fileReceiver); fileReceiver.activateOptions(); receiversPanel.updateReceiverTreeInDispatchThread(); } catch (URISyntaxException e1) { e1.printStackTrace(); } } } catch (IOException e1) { e1.printStackTrace(); } } } else if (receiverConfigurationPanel.getModel().isLoadConfig()) { configURL = receiverConfigurationPanel.getModel().getConfigToLoad(); } else if (receiverConfigurationPanel.getModel().isLogFileReceiverConfig()) { try { URL fileURL = receiverConfigurationPanel.getModel().getLogFileURL(); if (fileURL != null) { VFSLogFilePatternReceiver fileReceiver = new VFSLogFilePatternReceiver(); fileReceiver.setName(fileURL.getFile()); fileReceiver.setAutoReconnect(true); fileReceiver.setContainer(LogUI.this); fileReceiver.setAppendNonMatches(true); fileReceiver.setFileURL(fileURL.toURI().toString()); fileReceiver.setTailing(true); if (receiverConfigurationPanel.getModel().isPatternLayoutLogFormat()) { fileReceiver.setLogFormat( LogFilePatternLayoutBuilder.getLogFormatFromPatternLayout( receiverConfigurationPanel.getModel().getLogFormat())); } else { fileReceiver .setLogFormat(receiverConfigurationPanel.getModel().getLogFormat()); } fileReceiver.setTimestampFormat( receiverConfigurationPanel.getModel().getLogFormatTimestampFormat()); fileReceiver.setThreshold(Level.TRACE); pluginRegistry.addPlugin(fileReceiver); fileReceiver.activateOptions(); receiversPanel.updateReceiverTreeInDispatchThread(); } } catch (Exception e2) { MessageCenter.getInstance().getLogger().error("Error creating Receiver", e2); MessageCenter.getInstance().getLogger() .info("An error occurred creating your Receiver"); } } if (configURL == null && receiverConfigurationPanel.isDontWarnMeAgain()) { //use the saved config file as the config URL if defined if (receiverConfigurationPanel.getModel().getSaveConfigFile() != null) { try { configURL = receiverConfigurationPanel.getModel().getSaveConfigFile().toURI() .toURL(); } catch (MalformedURLException e1) { e1.printStackTrace(); } } else { //no saved config defined but don't warn me is checked - use default config configURL = receiverConfigurationPanel.getModel().getDefaultConfigFileURL(); } } if (configURL != null) { MessageCenter.getInstance().getLogger() .debug("Initialiazing Log4j with " + configURL.toExternalForm()); final URL finalURL = configURL; new Thread(new Runnable() { public void run() { if (receiverConfigurationPanel.isDontWarnMeAgain()) { applicationPreferenceModel.setConfigurationURL(finalURL.toExternalForm()); } else { try { if (new File(finalURL.toURI()).exists()) { loadConfigurationUsingPluginClassLoader(finalURL); } } catch (URISyntaxException e) { //ignore } } receiversPanel.updateReceiverTreeInDispatchThread(); } }).start(); } File saveConfigFile = receiverConfigurationPanel.getModel().getSaveConfigFile(); if (saveConfigFile != null) { ReceiversHelper.getInstance().saveReceiverConfiguration(saveConfigFile); } } }); receiverConfigurationPanel.setDialog(dialog); dialog.getContentPane().add(receiverConfigurationPanel); dialog.pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); dialog.setLocation((screenSize.width / 2) - (dialog.getWidth() / 2), (screenSize.height / 2) - (dialog.getHeight() / 2)); dialog.setVisible(true); } }); }
From source file:org.apache.marmotta.splash.common.ui.MessageDialog.java
public static void show(String title, String message, String description) { final JDialog dialog = new JDialog((Frame) null, title); dialog.setModal(true);/*from www .ja v a 2s. c om*/ dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); final JPanel root = new JPanel(new GridBagLayout()); root.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); dialog.getRootPane().setContentPane(root); final JButton close = new JButton("OK"); close.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); } }); GridBagConstraints cClose = new GridBagConstraints(); cClose.gridx = 0; cClose.gridy = 2; cClose.gridwidth = 2; cClose.weightx = 1; cClose.weighty = 0; cClose.insets = new Insets(5, 5, 5, 5); root.add(close, cClose); dialog.getRootPane().setDefaultButton(close); Icon icon = loadIcon(MARMOTTA_ICON); if (icon != null) { JLabel lblIcn = new JLabel(icon); GridBagConstraints cIcon = new GridBagConstraints(); cIcon.gridx = 1; cIcon.gridy = 0; cIcon.gridheight = 2; cIcon.fill = GridBagConstraints.NONE; cIcon.weightx = 0; cIcon.weighty = 1; cIcon.anchor = GridBagConstraints.NORTH; cIcon.insets = new Insets(10, 5, 5, 0); root.add(lblIcn, cIcon); } JLabel lblMsg = new JLabel("<html>" + StringEscapeUtils.escapeHtml3(message).replaceAll("\\n", "<br>")); lblMsg.setFont(lblMsg.getFont().deriveFont(Font.BOLD, 16f)); GridBagConstraints cLabel = new GridBagConstraints(); cLabel.gridx = 0; cLabel.gridy = 0; cLabel.fill = GridBagConstraints.BOTH; cLabel.weightx = 1; cLabel.weighty = 0.5; cLabel.insets = new Insets(5, 5, 5, 5); root.add(lblMsg, cLabel); JLabel lblDescr = new JLabel( "<html>" + StringEscapeUtils.escapeHtml3(description).replaceAll("\\n", "<br>")); cLabel.gridy++; cLabel.insets = new Insets(0, 5, 5, 5); root.add(lblDescr, cLabel); dialog.pack(); dialog.setLocationRelativeTo(null); dialog.setVisible(true); dialog.dispose(); }
From source file:org.apache.marmotta.splash.common.ui.SelectionDialog.java
public static int select(String title, String message, String description, List<Option> options, int defaultOption) { final JDialog dialog = new JDialog((Frame) null, title); dialog.setModal(true);// ww w .j a va2 s.co m dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); final AtomicInteger result = new AtomicInteger(Math.max(defaultOption, -1)); JButton defaultBtn = null; final JPanel root = new JPanel(new GridBagLayout()); root.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); dialog.getRootPane().setContentPane(root); JLabel lblMsg = new JLabel("<html>" + StringEscapeUtils.escapeHtml3(message).replaceAll("\\n", "<br>")); lblMsg.setFont(lblMsg.getFont().deriveFont(Font.BOLD, 16f)); GridBagConstraints cLabel = new GridBagConstraints(); cLabel.gridx = 0; cLabel.gridy = 0; cLabel.fill = GridBagConstraints.BOTH; cLabel.weightx = 1; cLabel.weighty = 0.5; cLabel.insets = new Insets(5, 5, 5, 5); root.add(lblMsg, cLabel); JLabel lblDescr = new JLabel( "<html>" + StringEscapeUtils.escapeHtml3(description).replaceAll("\\n", "<br>")); cLabel.gridy++; cLabel.insets = new Insets(0, 5, 5, 5); root.add(lblDescr, cLabel); // All the options cLabel.ipadx = 10; cLabel.ipady = 10; cLabel.insets = new Insets(5, 15, 0, 15); for (int i = 0; i < options.size(); i++) { cLabel.gridy++; final Option o = options.get(i); final JButton btn = new JButton( "<html>" + StringEscapeUtils.escapeHtml3(o.label).replaceAll("\\n", "<br>"), MessageDialog.loadIcon(o.icon)); if (StringUtils.isNotBlank(o.info)) { btn.setToolTipText("<html>" + StringEscapeUtils.escapeHtml3(o.info).replaceAll("\\n", "<br>")); } btn.setHorizontalAlignment(AbstractButton.LEADING); btn.setVerticalTextPosition(AbstractButton.CENTER); btn.setHorizontalTextPosition(AbstractButton.TRAILING); final int myAnswer = i; btn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { result.set(myAnswer); dialog.setVisible(false); } }); root.add(btn, cLabel); if (i == defaultOption) { dialog.getRootPane().setDefaultButton(btn); defaultBtn = btn; } } final Icon icon = MessageDialog.loadIcon(); if (icon != null) { JLabel lblIcn = new JLabel(icon); GridBagConstraints cIcon = new GridBagConstraints(); cIcon.gridx = 1; cIcon.gridy = 0; cIcon.gridheight = 2 + options.size(); cIcon.fill = GridBagConstraints.NONE; cIcon.weightx = 0; cIcon.weighty = 1; cIcon.anchor = GridBagConstraints.NORTH; cIcon.insets = new Insets(10, 5, 5, 0); root.add(lblIcn, cIcon); } final JButton close = new JButton("Cancel"); close.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { result.set(-1); dialog.setVisible(false); } }); GridBagConstraints cClose = new GridBagConstraints(); cClose.gridx = 0; cClose.gridy = 2 + options.size(); cClose.gridwidth = 2; cClose.weightx = 1; cClose.weighty = 0; cClose.insets = new Insets(15, 5, 5, 5); root.add(close, cClose); if (defaultOption < 0) { dialog.getRootPane().setDefaultButton(close); defaultBtn = close; } dialog.pack(); dialog.setLocationRelativeTo(null); defaultBtn.requestFocusInWindow(); dialog.setVisible(true); dialog.dispose(); return result.get(); }
From source file:org.apache.tika.gui.TikaGUI.java
private void handleError(String name, Throwable t) { StringWriter writer = new StringWriter(); writer.append("Apache Tika was unable to parse the document\n"); writer.append("at " + name + ".\n\n"); writer.append("The full exception stack trace is included below:\n\n"); t.printStackTrace(new PrintWriter(writer)); JEditorPane editor = new JEditorPane("text/plain", writer.toString()); editor.setEditable(false);// w ww . j av a 2 s . c o m editor.setBackground(Color.WHITE); editor.setCaretPosition(0); editor.setPreferredSize(new Dimension(600, 400)); JDialog dialog = new JDialog(this, "Apache Tika error"); dialog.add(new JScrollPane(editor)); dialog.pack(); dialog.setVisible(true); }
From source file:org.apache.tika.gui.TikaGUI.java
private void textDialog(String title, URL resource) { try {//ww w .j a va2s .c o m JDialog dialog = new JDialog(this, title); JEditorPane editor = new JEditorPane(resource); editor.setContentType("text/html"); editor.setEditable(false); editor.setBackground(Color.WHITE); editor.setPreferredSize(new Dimension(400, 250)); editor.addHyperlinkListener(this); dialog.add(editor); dialog.pack(); dialog.setVisible(true); } catch (IOException e) { e.printStackTrace(); } }
From source file:org.apache.tika.gui.TikaGUI.java
public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == EventType.ACTIVATED) { try {//from w w w .j av a 2s .co m URL url = e.getURL(); try (InputStream stream = url.openStream()) { JEditorPane editor = new JEditorPane("text/plain", IOUtils.toString(stream, UTF_8)); editor.setEditable(false); editor.setBackground(Color.WHITE); editor.setCaretPosition(0); editor.setPreferredSize(new Dimension(600, 400)); String name = url.toString(); name = name.substring(name.lastIndexOf('/') + 1); JDialog dialog = new JDialog(this, "Apache Tika: " + name); dialog.add(new JScrollPane(editor)); dialog.pack(); dialog.setVisible(true); } } catch (IOException exception) { exception.printStackTrace(); } } }
From source file:org.apache.uima.tools.docanalyzer.DBAnnotationViewerDialog.java
public void launchThatViewer(String xmi_id, TypeSystem typeSystem, final String[] aTypesToDisplay, boolean javaViewerRBisSelected, boolean javaViewerUCRBisSelected, boolean xmlRBisSelected, File styleMapFile, File viewerDirectory) { try {//w w w . j a v a2 s.co m InputStream xmiDocument = this.xmiDAO.getXMI(xmi_id); // create a new CAS CAS cas = CasCreationUtils.createCas(Collections.EMPTY_LIST, typeSystem, UIMAFramework.getDefaultPerformanceTuningProperties()); if (this.med1.isUmcompress()) { //Descomprime el XMI System.out.println("con compresin"); //Create the decompressor and give it the data to compress Inflater decompressor = new Inflater(); byte[] documentDataByteArray = IOUtils.toByteArray(xmiDocument); decompressor.setInput(documentDataByteArray); //Create an expandable byte array to hold the decompressed data ByteArrayOutputStream bos = new ByteArrayOutputStream(documentDataByteArray.length); //Decompress the data byte[] buf = new byte[1024]; while (!decompressor.finished()) { int count = decompressor.inflate(buf); bos.write(buf, 0, count); } bos.close(); //Get the decompressed data byte[] decompressedData = bos.toByteArray(); XmiCasDeserializer.deserialize(new ByteArrayInputStream(decompressedData), cas, true); } else { System.out.println("sin compresin"); XmlCasDeserializer.deserialize(xmiDocument, cas, true); } //get the specified view cas = cas.getView(this.defaultCasViewName); //launch appropriate viewer if (javaViewerRBisSelected || javaViewerUCRBisSelected) { // JMP // record preference for next time med1.setViewType(javaViewerRBisSelected ? "Java Viewer" : "JV User Colors"); //create tree viewer component CasAnnotationViewer viewer = new CasAnnotationViewer(); viewer.setDisplayedTypes(aTypesToDisplay); if (javaViewerUCRBisSelected) getColorsForTypesFromFile(viewer, styleMapFile); else viewer.setHiddenTypes(new String[] { "uima.cpm.FileLocation" }); // launch viewer in a new dialog viewer.setCAS(cas); JDialog dialog = new JDialog(DBAnnotationViewerDialog.this, "Annotation Results for " + xmi_id + " in " + inputDirPath); // JMP dialog.getContentPane().add(viewer); dialog.setSize(850, 630); dialog.pack(); dialog.show(); } else { CAS defaultView = cas.getView(CAS.NAME_DEFAULT_SOFA); if (defaultView.getDocumentText() == null) { displayError( "The HTML and XML Viewers can only view the default text document, which was not found in this CAS."); return; } // generate inline XML File inlineXmlFile = new File(viewerDirectory, "inline.xml"); String xmlAnnotations = new CasToInlineXml().generateXML(defaultView); FileOutputStream outStream = new FileOutputStream(inlineXmlFile); outStream.write(xmlAnnotations.getBytes("UTF-8")); outStream.close(); if (xmlRBisSelected) // JMP passed in { // record preference for next time med1.setViewType("XML"); BrowserUtil.openUrlInDefaultBrowser(inlineXmlFile.getAbsolutePath()); } else // HTML view { med1.setViewType("HTML"); // generate HTML view // first process style map if not done already if (!processedStyleMap) { if (!styleMapFile.exists()) { annotationViewGenerator.autoGenerateStyleMapFile( promptForAE().getAnalysisEngineMetaData(), styleMapFile); } annotationViewGenerator.processStyleMap(styleMapFile); processedStyleMap = true; } annotationViewGenerator.processDocument(inlineXmlFile); File genFile = new File(viewerDirectory, "index.html"); // open in browser BrowserUtil.openUrlInDefaultBrowser(genFile.getAbsolutePath()); } } // end LTV here } catch (Exception ex) { displayError(ex); } }
From source file:org.barcelonamedia.uima.tools.docanalyzer.DBAnnotationViewerDialog.java
public void launchThatViewer(String xmi_id, TypeSystem typeSystem, final String[] aTypesToDisplay, boolean javaViewerRBisSelected, boolean javaViewerUCRBisSelected, boolean xmlRBisSelected, File styleMapFile, File viewerDirectory) { try {//w w w .j a v a 2s .c om InputStream xmiDocument = this.xmiDAO.getXMI(xmi_id); // create a new CAS CAS cas = CasCreationUtils.createCas(Collections.EMPTY_LIST, typeSystem, UIMAFramework.getDefaultPerformanceTuningProperties()); if (this.med1.isUmcompress()) { //Descomprime el XMI //Create the decompressor and give it the data to compress Inflater decompressor = new Inflater(); byte[] documentDataByteArray = IOUtils.toByteArray(xmiDocument); decompressor.setInput(documentDataByteArray); //Create an expandable byte array to hold the decompressed data ByteArrayOutputStream bos = new ByteArrayOutputStream(documentDataByteArray.length); //Decompress the data byte[] buf = new byte[1024]; while (!decompressor.finished()) { int count = decompressor.inflate(buf); bos.write(buf, 0, count); } bos.close(); //Get the decompressed data byte[] decompressedData = bos.toByteArray(); XmiCasDeserializer.deserialize(new ByteArrayInputStream(decompressedData), cas, true); } else { XmlCasDeserializer.deserialize(xmiDocument, cas, true); } //get the specified view cas = cas.getView(this.defaultCasViewName); //launch appropriate viewer if (javaViewerRBisSelected || javaViewerUCRBisSelected) { // JMP // record preference for next time med1.setViewType(javaViewerRBisSelected ? "Java Viewer" : "JV User Colors"); //create tree viewer component CasAnnotationViewer viewer = new CasAnnotationViewer(); viewer.setDisplayedTypes(aTypesToDisplay); if (javaViewerUCRBisSelected) getColorsForTypesFromFile(viewer, styleMapFile); else viewer.setHiddenTypes(new String[] { "uima.cpm.FileLocation" }); // launch viewer in a new dialog viewer.setCAS(cas); JDialog dialog = new JDialog(DBAnnotationViewerDialog.this, "Annotation Results for " + xmi_id + " in " + inputDirPath); // JMP dialog.getContentPane().add(viewer); dialog.setSize(850, 630); dialog.pack(); dialog.show(); } else { CAS defaultView = cas.getView(CAS.NAME_DEFAULT_SOFA); if (defaultView.getDocumentText() == null) { displayError( "The HTML and XML Viewers can only view the default text document, which was not found in this CAS."); return; } // generate inline XML File inlineXmlFile = new File(viewerDirectory, "inline.xml"); String xmlAnnotations = new CasToInlineXml().generateXML(defaultView); FileOutputStream outStream = new FileOutputStream(inlineXmlFile); outStream.write(xmlAnnotations.getBytes("UTF-8")); outStream.close(); if (xmlRBisSelected) // JMP passed in { // record preference for next time med1.setViewType("XML"); BrowserUtil.openUrlInDefaultBrowser(inlineXmlFile.getAbsolutePath()); } else // HTML view { med1.setViewType("HTML"); // generate HTML view // first process style map if not done already if (!processedStyleMap) { if (!styleMapFile.exists()) { annotationViewGenerator.autoGenerateStyleMapFile( promptForAE().getAnalysisEngineMetaData(), styleMapFile); } annotationViewGenerator.processStyleMap(styleMapFile); processedStyleMap = true; } annotationViewGenerator.processDocument(inlineXmlFile); File genFile = new File(viewerDirectory, "index.html"); // open in browser BrowserUtil.openUrlInDefaultBrowser(genFile.getAbsolutePath()); } } // end LTV here } catch (Exception ex) { displayError(ex); } }
From source file:org.deegree.tools.rendering.viewer.File3dImporter.java
public static List<WorldRenderableObject> open(Frame parent, String fileName) { if (fileName == null || "".equals(fileName.trim())) { throw new InvalidParameterException("the file name may not be null or empty"); }/*ww w .jav a 2 s.c o m*/ fileName = fileName.trim(); CityGMLImporter openFile2; XMLInputFactory fac = XMLInputFactory.newInstance(); InputStream in = null; try { XMLStreamReader reader = fac.createXMLStreamReader(in = new FileInputStream(fileName)); reader.next(); String ns = "http://www.opengis.net/citygml/1.0"; openFile2 = new CityGMLImporter(null, null, null, reader.getNamespaceURI().equals(ns)); } catch (Throwable t) { openFile2 = new CityGMLImporter(null, null, null, false); } finally { IOUtils.closeQuietly(in); } final CityGMLImporter openFile = openFile2; final JDialog dialog = new JDialog(parent, "Loading", true); dialog.getContentPane().setLayout(new BorderLayout()); dialog.getContentPane().add( new JLabel("<HTML>Loading file:<br>" + fileName + "<br>Please wait!</HTML>", SwingConstants.CENTER), BorderLayout.NORTH); final JProgressBar progressBar = new JProgressBar(); progressBar.setStringPainted(true); progressBar.setIndeterminate(false); dialog.getContentPane().add(progressBar, BorderLayout.CENTER); dialog.pack(); dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); dialog.setResizable(false); dialog.setLocationRelativeTo(parent); final Thread openThread = new Thread() { /** * Opens the file in a separate thread. */ @Override public void run() { // openFile.openFile( progressBar ); if (dialog.isDisplayable()) { dialog.setVisible(false); dialog.dispose(); } } }; openThread.start(); dialog.setVisible(true); List<WorldRenderableObject> result = null; try { result = openFile.importFromFile(fileName, 6, 2); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } gm = openFile.getQmList(); // // if ( result != null ) { // openGLEventListener.addDataObjectToScene( result ); // File f = new File( fileName ); // setTitle( WIN_TITLE + f.getName() ); // } else { // showExceptionDialog( "The file: " + fileName // + " could not be read,\nSee error log for detailed information." ); // } return result; }
From source file:org.drugis.addis.gui.WelcomeDialog.java
private void showExampleInfo(String helpText) { final JDialog dialog = new JDialog(this); dialog.setLocationByPlatform(true);//from w ww. j ava 2 s . c o m 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); }