List of usage examples for javax.swing JDialog JDialog
public JDialog(Window owner, String title, Dialog.ModalityType modalityType)
From source file:org.accada.reader.hal.impl.sim.GraphicSimulator.java
/** * creates the help menu item if it does not already exists * /* w ww .ja v a 2s .c om*/ * @return help menu */ private JMenu getHelpMenu() { JMenu helpMenu = new JMenu(guiText.getString("HelpMenuItem")); // about JMenuItem aboutMenuItem = new JMenuItem(); aboutMenuItem.setText(guiText.getString("AboutMenuItem")); aboutMenuItem.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { JDialog aboutDialog = new JDialog(GraphicSimulator.this, guiText.getString("AboutDialogTitle"), true); Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; aboutDialog.setLocation(pos); aboutDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); aboutDialog.setTitle(guiText.getString("AboutDialogTitle")); JLabel text = new JLabel(guiText.getString("AboutDialogContent")); text.setHorizontalAlignment(JLabel.CENTER); aboutDialog.add(text); aboutDialog.setVisible(true); } }); helpMenu.add(aboutMenuItem); return helpMenu; }
From source file:org.accada.reader.hal.impl.sim.GraphicSimulator.java
/** * shows the dialog menu to add a new antenna *//* w w w . j av a2 s. com*/ private void showAddAntennaDialog() { Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; if (newAntennaDialog == null) { newAntennaDialog = new JDialog(this, guiText.getString("AddNewAntennaDialogTitle"), true); newAntennaDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); newAntennaDialog.setLayout(new BorderLayout()); // input fields JLabel idLabel = new JLabel(guiText.getString("AntennaIdLabel") + ": "); final JTextField idField = new JTextField(); JPanel inputFields = new JPanel(); inputFields.setLayout(new GridLayout(2, 2)); inputFields.add(idLabel); inputFields.add(idField); // cancel button JButton cancelButton = new JButton(guiText.getString("CancelButton")); cancelButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newAntennaDialog.setVisible(false); idField.setText(""); } }); // add button JButton addButton = new JButton(guiText.getString("AddButton")); addButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newAntennaDialog.setVisible(false); createNewAntenna(idField.getText()); idField.setText(""); } }); // buttons panel JPanel buttons = new JPanel(); buttons.add(addButton); buttons.add(cancelButton); newAntennaDialog.add(inputFields, BorderLayout.CENTER); newAntennaDialog.add(buttons, BorderLayout.SOUTH); newAntennaDialog.getRootPane().setDefaultButton(addButton); } newAntennaDialog.setLocation(pos); newAntennaDialog.setVisible(true); }
From source file:org.accada.reader.hal.impl.sim.GraphicSimulator.java
/** * shows the dialog menu to add a new tag *//*from ww w . j a v a 2 s . c om*/ private void showAddTagDialog() { // compute position of the dialog final Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; // set default id String id = props.getProperty("TagPrefix"); for (int i = 0; i < 4 - new Integer(tags.size()).toString().length(); i++) { id += "0"; } id += tags.size(); if (tagIdField == null) { tagIdField = new JTextField(); } tagIdField.setText(id); // create tag dialog if it does not already exists if (newTagDialog == null) { newTagDialog = new JDialog(this, guiText.getString("AddNewTagDialogTitle"), true); newTagDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); newTagDialog.setLayout(new BorderLayout()); // input fields panel JLabel epcLabel = new JLabel(guiText.getString("TagIdLabel") + ": "); JPanel inputFields = new JPanel(); inputFields.setLayout(new GridLayout(2, 2)); inputFields.add(epcLabel); inputFields.add(tagIdField); // cancel button JButton cancelButton = new JButton(guiText.getString("CancelButton")); cancelButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newTagDialog.setVisible(false); } }); // add button JButton addButton = new JButton(guiText.getString("AddButton")); addButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newTagDialog.setVisible(false); createNewTag(tagIdField.getText()); } }); // buttons panel JPanel buttons = new JPanel(); buttons.add(addButton); buttons.add(cancelButton); // compose all together newTagDialog.add(inputFields, BorderLayout.CENTER); newTagDialog.add(buttons, BorderLayout.SOUTH); newTagDialog.getRootPane().setDefaultButton(addButton); } newTagDialog.setLocation(pos); newTagDialog.setVisible(true); }
From source file:org.accada.reader.hal.impl.sim.multi.GraphicSimulatorServer.java
/** * creates the help menu item//from w ww. j av a 2 s. c om * * @return help menu */ private JMenu getHelpMenu() { JMenu helpMenu = new JMenu(guiText.getString("HelpMenuItem")); // about JMenuItem aboutMenuItem = new JMenuItem(); aboutMenuItem.setText(guiText.getString("AboutMenuItem")); aboutMenuItem.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { JDialog aboutDialog = new JDialog(GraphicSimulatorServer.this, guiText.getString("AboutDialogTitle"), true); Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; aboutDialog.setLocation(pos); aboutDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); aboutDialog.setTitle(guiText.getString("AboutDialogTitle")); JLabel text = new JLabel(guiText.getString("AboutDialogContent")); text.setHorizontalAlignment(JLabel.CENTER); aboutDialog.add(text); aboutDialog.setVisible(true); } }); helpMenu.add(aboutMenuItem); return helpMenu; }
From source file:org.accada.reader.hal.impl.sim.multi.GraphicSimulatorServer.java
/** * shows the dialog menu to add a new tag *//*from ww w . j a v a 2s . c o m*/ private void showAddTagDialog() { // compute position of the dialog final Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; // set default id String id = "A47033F"; for (int i = 0; i < 4 - new Integer(tags.size()).toString().length(); i++) { id += "0"; } id += tags.size(); if (tagIdField == null) { tagIdField = new JTextField(); } tagIdField.setText(id); // create tag dialog if it does not already exists if (newTagDialog == null) { newTagDialog = new JDialog(this, guiText.getString("AddNewTagDialogTitle"), true); newTagDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); newTagDialog.setLayout(new BorderLayout()); // input fields panel JLabel epcLabel = new JLabel(guiText.getString("TagIdLabel") + ": "); JPanel inputFields = new JPanel(); inputFields.setLayout(new GridLayout(2, 2)); inputFields.add(epcLabel); inputFields.add(tagIdField); // cancel button JButton cancelButton = new JButton(guiText.getString("CancelButton")); cancelButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newTagDialog.setVisible(false); } }); // add button JButton addButton = new JButton(guiText.getString("AddButton")); addButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newTagDialog.setVisible(false); createNewTag(tagIdField.getText()); } }); // buttons panel JPanel buttons = new JPanel(); buttons.add(addButton); buttons.add(cancelButton); // compose all together newTagDialog.add(inputFields, BorderLayout.CENTER); newTagDialog.add(buttons, BorderLayout.SOUTH); newTagDialog.getRootPane().setDefaultButton(addButton); } newTagDialog.setLocation(pos); newTagDialog.setVisible(true); }
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"); }/*from w w w .j a v 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.executequery.components.FileChooserDialog.java
protected JDialog createDialog(Component parent) throws HeadlessException { Frame frame = parent instanceof Frame ? (Frame) parent : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent); String title = getUI().getDialogTitle(this); JDialog dialog = new JDialog(frame, title, true); Container contentPane = dialog.getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.add(this, BorderLayout.CENTER); setPreferredSize(new Dimension(700, getPreferredSize().height)); // add any custom panel if (customPanel != null) { contentPane.add(customPanel, BorderLayout.SOUTH); }// w ww. j a v a 2 s. c o m if (JDialog.isDefaultLookAndFeelDecorated()) { boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations(); if (supportsWindowDecorations) { dialog.getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG); } } setFileView(new DefaultFileView()); dialog.pack(); dialog.setLocation(GUIUtilities.getLocationForDialog(dialog.getSize())); return dialog; }
From source file:org.interreg.docexplore.DocExploreTool.java
@SuppressWarnings("serial") protected static File askForHome(String text) { final File[] file = { null }; final JDialog dialog = new JDialog((Frame) null, XMLResourceBundle.getBundledString("homeLabel"), true); JPanel content = new JPanel(new LooseGridLayout(0, 1, 10, 10, true, false, SwingConstants.CENTER, SwingConstants.TOP, true, false)); content.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); JLabel message = new JLabel(text, ImageUtils.getIcon("free-64x64.png"), SwingConstants.LEFT); message.setIconTextGap(20);/*from w w w . j a v a2 s.c o m*/ //message.setFont(Font.decode(Font.SANS_SERIF)); content.add(message); final JPanel pathPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10)); pathPanel.add(new JLabel("<html><b>" + XMLResourceBundle.getBundledString("homeLabel") + ":</b></html>")); final JTextField pathField = new JTextField(System.getProperty("user.home") + File.separator + "DocExplore", 40); pathPanel.add(pathField); pathPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("browseLabel")) { JNativeFileDialog nfd = null; public void actionPerformed(ActionEvent arg0) { if (nfd == null) { nfd = new JNativeFileDialog(); nfd.acceptFiles = false; nfd.acceptFolders = true; nfd.multipleSelection = false; nfd.title = XMLResourceBundle.getBundledString("homeLabel"); } nfd.setCurrentFile(new File(pathField.getText())); if (nfd.showOpenDialog()) pathField.setText(nfd.getSelectedFile().getAbsolutePath()); } })); content.add(pathPanel); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10)); buttonPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgOkLabel")) { public void actionPerformed(ActionEvent e) { File res = new File(pathField.getText()); if (res.exists() && !res.isDirectory() || !res.exists() && !res.mkdirs()) JOptionPane.showMessageDialog(dialog, XMLResourceBundle.getBundledString("homeErrorMessage"), XMLResourceBundle.getBundledString("errorLabel"), JOptionPane.ERROR_MESSAGE); else { file[0] = res; dialog.setVisible(false); } } })); buttonPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgCancelLabel")) { public void actionPerformed(ActionEvent e) { dialog.setVisible(false); } })); content.add(buttonPanel); dialog.getContentPane().add(content); dialog.pack(); dialog.setResizable(false); GuiUtils.centerOnScreen(dialog); dialog.setVisible(true); return file[0]; }
From source file:org.myrobotlab.service.MarySpeech.java
private void showProgressPanel(List<ComponentDescription> comps, boolean install) { final ProgressPanel pp = new ProgressPanel(comps, install); final JOptionPane optionPane = new JOptionPane(pp, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new String[] { "Abort" }, "Abort"); // optionPane.setPreferredSize(new Dimension(640,480)); final JDialog dialog = new JDialog((Frame) null, "Progress", false); dialog.setContentPane(optionPane);//www . j a v a 2s .co m optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { pp.requestExit(); dialog.setVisible(false); } } }); dialog.pack(); dialog.setVisible(true); new Thread(pp).start(); }
From source file:org.nuclos.client.main.mainframe.workspace.WorkspaceEditor.java
public WorkspaceEditor(WorkspaceVO wovo) { final SpringLocaleDelegate localeDelegate = SpringLocaleDelegate.getInstance(); this.wovo = wovo; this.backup = new WorkspaceVO(); this.backup.importHeader(wovo.getWoDesc()); boolean showAlwaysReset = wovo.isAssigned() && SecurityCache.getInstance().isActionAllowed(Actions.ACTION_WORKSPACE_ASSIGN); contentPanel = new JPanel(); initJPanel(contentPanel,// w w w . j ava 2 s .c o m new double[] { TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL }, new double[] { 20, 20, 20, 20, showAlwaysReset ? 20 : 0, 10, 20, TableLayout.FILL, TableLayout.PREFERRED }); contentPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JLabel lbName = new JLabel(localeDelegate.getMessage("WorkspaceEditor.2", "Name"), JLabel.TRAILING); contentPanel.add(lbName, "0, 0"); tfName = new JTextField(15); lbName.setLabelFor(tfName); contentPanel.add(tfName, "1, 0"); chckHideName = new JCheckBox(localeDelegate.getMessage("WorkspaceEditor.3", "Name ausblenden")); contentPanel.add(chckHideName, "2, 0, 3, 0"); chckHide = new JCheckBox(localeDelegate.getMessage("WorkspaceEditor.8", "Auswahl Button ausblenden")); if (wovo.isAssigned() && SecurityCache.getInstance().isActionAllowed(Actions.ACTION_WORKSPACE_ASSIGN)) { contentPanel.add(chckHide, "4, 0"); } chckAlwaysOpenAtLogin = new JCheckBox( localeDelegate.getMessage("WorkspaceEditor.11", "Immer bei Anmeldung ffnen")); contentPanel.add(chckAlwaysOpenAtLogin, "1, 1"); JLabel lbMainFrame = new JLabel(localeDelegate.getMessage("WorkspaceEditor.9", "Hauptfenster"), JLabel.TRAILING); contentPanel.add(lbMainFrame, "0, 2"); chckHideMenuBar = new JCheckBox(localeDelegate.getMessage("WorkspaceEditor.10", "Nur Standard Menuleiste")); contentPanel.add(chckHideMenuBar, "1, 2"); chckUseLastFrameSettings = new JCheckBox(localeDelegate.getMessage("WorkspaceEditor.12", "Letzte Fenster Einstellungen bernehmen (Gre und Position)")); contentPanel.add(chckUseLastFrameSettings, "1, 3, 5, 3"); chckAlwaysReset = new JCheckBox(localeDelegate.getMessage("WorkspaceEditor.alwaysreset", "Zuletzt geffnete Tabs immer zurcksetzen")); if (showAlwaysReset) { contentPanel.add(chckAlwaysReset, "1, 4, 5, 4"); } JTabbedPane tbbdPane = new JTabbedPane(); nuclosIconChooser = new ResourceIconChooser(WorkspaceChooserController.ICON_SIZE, NuclosResourceCategory.ENTITY_ICON); nuclosIconChooser.removeBorder(); tbbdPane.addTab(localeDelegate.getMessage("WorkspaceEditor.4", "Icon"), nuclosIconChooser); JPanel parameterPanel = new JPanel(new BorderLayout()); parameterModel = new ParameterModel(); jtbParameter = new JTable(parameterModel); JScrollPane parameterScroller = new JScrollPane(jtbParameter); jtbParameter.setFillsViewportHeight(true); jtbParameter.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); jtbParameter.getColumnModel().getColumn(0).setPreferredWidth(100); jtbParameter.getColumnModel().getColumn(1).setPreferredWidth(400); parameterPanel.add(parameterScroller, BorderLayout.CENTER); JToolBar parameterTools = UIUtils.createNonFloatableToolBar(JToolBar.VERTICAL); parameterTools.add(new ParameterAddButton()); btRemoveParameter = new ParameterRemoveButton(); btRemoveParameter.setEnabled(false); parameterTools.add(btRemoveParameter); parameterPanel.add(parameterTools, BorderLayout.WEST); tbbdPane.addTab(localeDelegate.getMessage("WorkspaceEditor.13", "Parameter"), parameterPanel); contentPanel.add(tbbdPane, "1, 6, 5, 7"); JPanel actionsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 2)); btSave = new JButton(localeDelegate.getMessage("WorkspaceEditor.5", "Speichern")); btCancel = new JButton(localeDelegate.getMessage("WorkspaceEditor.6", "Abbrechen")); actionsPanel.add(btSave); actionsPanel.add(btCancel); contentPanel.add(actionsPanel, "0, 8, 5, 8"); tfName.setText(wovo.getWoDesc().getName()); chckHide.setSelected(wovo.getWoDesc().isHide()); chckHideName.setSelected(wovo.getWoDesc().isHideName()); chckHideMenuBar.setSelected(wovo.getWoDesc().isHideMenuBar()); chckAlwaysOpenAtLogin.setSelected(wovo.getWoDesc().isAlwaysOpenAtLogin()); chckUseLastFrameSettings.setSelected(wovo.getWoDesc().isUseLastFrameSettings()); chckAlwaysReset.setSelected(wovo.getWoDesc().isAlwaysReset()); nuclosIconChooser.setSelected(wovo.getWoDesc().getNuclosResource()); parameterModel.setParamters(wovo.getWoDesc().getParameters()); dialog = new JDialog(Main.getInstance().getMainFrame(), localeDelegate.getMessage("WorkspaceEditor.1", "Arbeitsumgebung Eigenschaften"), true); dialog.setContentPane(contentPanel); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.getRootPane().setDefaultButton(btSave); Rectangle mfBounds = Main.getInstance().getMainFrame().getBounds(); dialog.setBounds(mfBounds.x + (mfBounds.width / 2) - 300, mfBounds.y + (mfBounds.height / 2) - 200, 600, 400); dialog.setResizable(false); initListener(); dialog.setVisible(true); }