List of usage examples for javax.swing JDialog setVisible
public void setVisible(boolean b)
From source file:captureplugin.CapturePlugin.java
/** * Check the programs after data update. *///from w w w . j a v a 2 s. com public void handleTvDataUpdateFinished() { mNeedsUpdate = true; if (mAllowedToShowDialog) { mNeedsUpdate = false; DeviceIf[] devices = mConfig.getDeviceArray(); final DefaultTableModel model = new DefaultTableModel() { public boolean isCellEditable(int row, int column) { return false; } }; model.setColumnCount(5); model.setColumnIdentifiers(new String[] { mLocalizer.msg("device", "Device"), Localizer.getLocalization(Localizer.I18N_CHANNEL), mLocalizer.msg("date", "Date"), ProgramFieldType.START_TIME_TYPE.getLocalizedName(), ProgramFieldType.TITLE_TYPE.getLocalizedName() }); JTable table = new JTable(model); table.getTableHeader().setReorderingAllowed(false); table.getTableHeader().setResizingAllowed(false); table.getColumnModel().getColumn(0).setCellRenderer(new DefaultTableCellRenderer() { public Component getTableCellRendererComponent(JTable renderTable, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component c = super.getTableCellRendererComponent(renderTable, value, isSelected, hasFocus, row, column); if (value instanceof DeviceIf) { if (((DeviceIf) value).getDeleteRemovedProgramsAutomatically() && !isSelected) { c.setForeground(Color.red); } } return c; } }); int[] columnWidth = new int[5]; for (int i = 0; i < columnWidth.length; i++) { columnWidth[i] = UiUtilities.getStringWidth(table.getFont(), model.getColumnName(i)) + 10; } for (DeviceIf device : devices) { Program[] deleted = device.checkProgramsAfterDataUpdateAndGetDeleted(); if (deleted != null && deleted.length > 0) { for (Program p : deleted) { if (device.getDeleteRemovedProgramsAutomatically() && !p.isExpired() && !p.isOnAir()) { device.remove(UiUtilities.getLastModalChildOf(getParentFrame()), p); } else { device.removeProgramWithoutExecution(p); } if (!p.isExpired()) { Object[] o = new Object[] { device, p.getChannel().getName(), p.getDateString(), p.getTimeString(), p.getTitle() }; for (int i = 0; i < columnWidth.length; i++) { columnWidth[i] = Math.max(columnWidth[i], UiUtilities.getStringWidth(table.getFont(), o[i].toString()) + 10); } model.addRow(o); } } } device.getProgramList(); } if (model.getRowCount() > 0) { int sum = 0; for (int i = 0; i < columnWidth.length; i++) { table.getColumnModel().getColumn(i).setPreferredWidth(columnWidth[i]); if (i < columnWidth.length - 1) { table.getColumnModel().getColumn(i).setMaxWidth(columnWidth[i]); } sum += columnWidth[i]; } JScrollPane scrollPane = new JScrollPane(table); scrollPane.setPreferredSize(new Dimension(450, 250)); if (sum > 500) { table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); scrollPane.getViewport().setPreferredSize( new Dimension(sum, scrollPane.getViewport().getPreferredSize().height)); } JButton export = new JButton(mLocalizer.msg("exportList", "Export list")); export.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.setDialogType(JFileChooser.SAVE_DIALOG); chooser.setFileFilter(new FileFilter() { public boolean accept(File f) { return f.isDirectory() || f.toString().toLowerCase().endsWith(".txt"); } public String getDescription() { return "*.txt"; } }); chooser.setSelectedFile(new File("RemovedPrograms.txt")); if (chooser.showSaveDialog( UiUtilities.getLastModalChildOf(getParentFrame())) == JFileChooser.APPROVE_OPTION) { if (chooser.getSelectedFile() != null) { String file = chooser.getSelectedFile().getAbsolutePath(); if (!file.toLowerCase().endsWith(".txt") && file.indexOf('.') == -1) { file = file + ".txt"; } if (file.indexOf('.') != -1) { try { RandomAccessFile write = new RandomAccessFile(file, "rw"); write.setLength(0); String eolStyle = File.separator.equals("/") ? "\n" : "\r\n"; for (int i = 0; i < model.getRowCount(); i++) { StringBuilder line = new StringBuilder(); for (int j = 0; j < model.getColumnCount(); j++) { line.append(model.getValueAt(i, j)).append(' '); } line.append(eolStyle); write.writeBytes(line.toString()); } write.close(); } catch (Exception ee) { } } } } } }); Object[] message = { mLocalizer.msg("deletedText", "The data was changed and the following programs were deleted:"), scrollPane, export }; JOptionPane pane = new JOptionPane(); pane.setMessage(message); pane.setMessageType(JOptionPane.PLAIN_MESSAGE); final JDialog d = pane.createDialog(UiUtilities.getLastModalChildOf(getParentFrame()), mLocalizer.msg("CapturePlugin", "CapturePlugin") + " - " + mLocalizer.msg("deletedTitle", "Deleted programs")); d.setResizable(true); d.setModal(false); SwingUtilities.invokeLater(new Runnable() { public void run() { d.setVisible(true); } }); } } }
From source file:net.sf.jabref.gui.openoffice.StyleSelectDialog.java
private void displayStyle(OOBibStyle style) { // Make a dialog box to display the contents: final JDialog dd = new JDialog(diag, style.getName(), true); JTextArea ta = new JTextArea(style.getLocalCopy()); ta.setEditable(false);//from w w w. j a v a 2 s . com JScrollPane sp = new JScrollPane(ta); sp.setPreferredSize(new Dimension(700, 500)); dd.getContentPane().add(sp, BorderLayout.CENTER); JButton okButton = new JButton(Localization.lang("OK")); ButtonBarBuilder bb = new ButtonBarBuilder(); bb.addGlue(); bb.addButton(okButton); bb.addGlue(); bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); dd.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH); okButton.addActionListener(actionEvent -> dd.dispose()); dd.pack(); dd.setLocationRelativeTo(diag); dd.setVisible(true); }
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/*w ww .j a va2s. co m*/ 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:brainflow.app.toplevel.BrainFlow.java
private void initExceptionHandler() { LookAndFeelFactory.UIDefaultsCustomizer uiDefaultsCustomizer = new LookAndFeelFactory.UIDefaultsCustomizer() { public void customize(UIDefaults defaults) { ThemePainter painter = (ThemePainter) UIDefaultsLookup.get("Theme.painter"); defaults.put("OptionPaneUI", "com.jidesoft.plaf.basic.BasicJideOptionPaneUI"); defaults.put("OptionPane.showBanner", Boolean.TRUE); // show banner or not. default is true //defaults.put("OptionPane.bannerIcon", JideIconsFactory.getImageIcon(JideIconsFactory.JIDE50)); defaults.put("OptionPane.bannerFontSize", 13); defaults.put("OptionPane.bannerFontStyle", Font.BOLD); defaults.put("OptionPane.bannerMaxCharsPerLine", 60); defaults.put("OptionPane.bannerForeground", painter != null ? painter.getOptionPaneBannerForeground() : null); // you should adjust this if banner background is not the default gradient paint defaults.put("OptionPane.bannerBorder", null); // use default border // set both bannerBackgroundDk and // set both bannerBackgroundLt to null if you don't want gradient defaults.put("OptionPane.bannerBackgroundDk", painter != null ? painter.getOptionPaneBannerDk() : null); defaults.put("OptionPane.bannerBackgroundLt", painter != null ? painter.getOptionPaneBannerLt() : null); defaults.put("OptionPane.bannerBackgroundDirection", Boolean.TRUE); // default is true // optionally, you can set a Paint object for BannerPanel. If so, the three UIDefaults related to banner background above will be ignored. defaults.put("OptionPane.bannerBackgroundPaint", null); defaults.put("OptionPane.buttonAreaBorder", BorderFactory.createEmptyBorder(6, 6, 6, 6)); defaults.put("OptionPane.buttonOrientation", SwingConstants.RIGHT); }// ww w .j ava 2s. c om }; uiDefaultsCustomizer.customize(UIManager.getDefaults()); Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { e.printStackTrace(); ExceptionDialog ed = new ExceptionDialog(e); JDialog dialog = ed.createDialog(brainFrame); dialog.setVisible(true); } }); }
From source file:emailplugin.MailCreator.java
/** * Show the EMail-Open Dialog.//from w ww . j a v a 2 s. c o m * * This Dialog says that the EMail should have been opened. It gives the User * a chance to specify another EMail Program if it went wrong. * * @param parent * Parent-Frame */ private void showEMailOpenedDialog(Frame parent) { final JDialog dialog = new JDialog(parent, true); dialog.setTitle(mLocalizer.msg("EMailOpenedTitel", "Email was opened")); JPanel panel = (JPanel) dialog.getContentPane(); panel.setLayout(new FormLayout("fill:200dlu:grow", "default, 3dlu, default, 3dlu, default")); panel.setBorder(Borders.DIALOG_BORDER); CellConstraints cc = new CellConstraints(); panel.add(UiUtilities.createHelpTextArea(mLocalizer.msg("EMailOpened", "Email was opened. Configure it?")), cc.xy(1, 1)); final JCheckBox dontShowAgain = new JCheckBox( mLocalizer.msg("DontShowAgain", "Don't show this Dialog again")); panel.add(dontShowAgain, cc.xy(1, 3)); JButton configure = new JButton(mLocalizer.msg("configure", "Configure")); configure.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Plugin.getPluginManager().showSettings(mPlugin); dialog.setVisible(false); } }); JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK)); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (dontShowAgain.isSelected()) { mSettings.setShowEmailOpened(false); } dialog.setVisible(false); } }); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); buttonPanel.add(configure); buttonPanel.add(ok); panel.add(buttonPanel, cc.xy(1, 5)); UiUtilities.registerForClosing(new WindowClosingIf() { public void close() { dialog.setVisible(false); } public JRootPane getRootPane() { return dialog.getRootPane(); } }); dialog.getRootPane().setDefaultButton(ok); dialog.pack(); UiUtilities.centerAndShow(dialog); }
From source file:net.lmxm.ute.gui.MainFrame.java
/** * Action about./* www . ja v a2 s . co m*/ */ private void actionAbout() { final JDialog dialog = new AboutDialog(); GuiUtils.center(dialog); dialog.setVisible(true); }
From source file:hermes.browser.HermesBrowser.java
public void showErrorDialog(final String message, final Throwable t) { Runnable r = new Runnable() { public void run() { String detail = null; if (t instanceof PyException) { StringBuffer s = new StringBuffer(); PyException pyT = (PyException) t; pyT.traceback.dumpStack(s); detail = s.toString();/*ww w. ja v a 2s . co m*/ } else { StringWriter s = new StringWriter(); PrintWriter p = new PrintWriter(s); t.printStackTrace(p); detail = s.toString(); } JideOptionPane optionPane = new JideOptionPane(message, JOptionPane.ERROR_MESSAGE, JideOptionPane.CLOSE_OPTION, UIManager.getIcon("OptionPane.errorIcon")); optionPane.setTitle(message); if (detail != null) { optionPane.setDetails(detail); } JDialog dialog = optionPane.createDialog(HermesBrowser.this, "Error"); dialog.setResizable(true); dialog.pack(); dialog.setVisible(true); } }; if (SwingUtilities.isEventDispatchThread()) { r.run(); } else { SwingUtilities.invokeLater(r); } }
From source file:net.mariottini.swing.JFontChooser.java
/** * Show a "Choose Font" dialog with the specified title and modality. * /*from w w w . j a v a2s. co m*/ * @param parent * the parent component, or null to use a default root frame as parent. * @param title * the title for the dialog. * @param modal * true to show a modal dialog, false to show a non-modal dialog (in this case the * function will return immediately after making visible the dialog). * @return <code>APPROVE_OPTION</code> if the user chose a font, <code>CANCEL_OPTION</code> if the * user canceled the operation. <code>CANCEL_OPTION</code> is always returned for a * non-modal dialog, use an ActionListener to be notified when the user approves/cancels * the dialog. * @see #APPROVE_OPTION * @see #CANCEL_OPTION * @see #addActionListener */ public int showDialog(Component parent, String title, boolean modal) { final int[] result = new int[] { CANCEL_OPTION }; while (parent != null && !(parent instanceof Window)) { parent = parent.getParent(); } final JDialog d; if (parent instanceof Frame) { d = new JDialog((Frame) parent, title, modal); } else if (parent instanceof Dialog) { d = new JDialog((Dialog) parent, title, modal); } else { d = new JDialog(); d.setTitle(title); d.setModal(modal); } final ActionListener[] listener = new ActionListener[1]; listener[0] = new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals(APPROVE_SELECTION)) { result[0] = APPROVE_OPTION; } removeActionListener(listener[0]); d.setContentPane(new JPanel()); d.setVisible(false); d.dispose(); } }; addActionListener(listener[0]); d.setComponentOrientation(getComponentOrientation()); d.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); d.getContentPane().add(this, BorderLayout.CENTER); d.pack(); d.setLocationRelativeTo(parent); d.setVisible(true); return result[0]; }
From source file:de.dakror.virtualhub.server.dialog.BackupEditDialog.java
public static void show() throws JSONException { final JDialog dialog = new JDialog(Server.currentServer.frame, "Backup-Einstellungen", true); dialog.setSize(400, 250);// w w w . j a v a2 s. c om dialog.setLocationRelativeTo(Server.currentServer.frame); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); JPanel cp = new JPanel(new SpringLayout()); cp.add(new JLabel("Zielverzeichnis:")); JPanel panel = new JPanel(); final JTextField path = new JTextField((Server.currentServer.settings.has("backup.path") ? Server.currentServer.settings.getString("backup.path") : ""), 10); panel.add(path); panel.add(new JButton(new AbstractAction("Whlen...") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { JFileChooser jfc = new JFileChooser((path.getText().length() > 0 ? new File(path.getText()) : new File(System.getProperty("user.home")))); jfc.setFileHidingEnabled(false); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); jfc.setDialogTitle("Backup-Zielverzeichnis whlen"); if (jfc.showOpenDialog(dialog) == JFileChooser.APPROVE_OPTION) path.setText(jfc.getSelectedFile().getPath().replace("\\", "/")); } })); cp.add(panel); cp.add(new JLabel("")); cp.add(new JLabel("")); cp.add(new JButton(new AbstractAction("Abbrechen") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } })); cp.add(new JButton(new AbstractAction("Speichern") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { try { if (path.getText().length() > 0) Server.currentServer.settings.put("backup.path", path.getText()); dialog.dispose(); } catch (JSONException e1) { e1.printStackTrace(); } } })); SpringUtilities.makeCompactGrid(cp, 3, 2, 6, 6, 6, 6); dialog.setContentPane(cp); dialog.pack(); dialog.setVisible(true); }
From source file:org.moeaframework.analysis.plot.Plot.java
/** * Displays the chart in a blocking JDialog. * //from w ww.ja va 2 s . c om * @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; }