Example usage for javax.swing JDialog setResizable

List of usage examples for javax.swing JDialog setResizable

Introduction

In this page you can find the example usage for javax.swing JDialog setResizable.

Prototype

public void setResizable(boolean resizable) 

Source Link

Document

Sets whether this dialog is resizable by the user.

Usage

From source file:esmska.gui.AboutFrame.java

private void creditsButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_creditsButtonActionPerformed
    //show credits
    try {//from   w  ww .  j  a v a  2s . com
        logger.fine("Showing credits...");
        String credits = IOUtils.toString(getClass().getResourceAsStream(RES + "credits.html"), "UTF-8");
        String translators = l10n.getString("Translators");
        if ("translator-credits".equals(translators)) {
            //there are no translators mentioned
            translators = "";
        } else {
            translators = translators.replaceAll("\n", "<br>\n").replaceAll("\n  ", "\n&nbsp;&nbsp;");
            //add hyperlinks to the Launchpad URLs
            translators = translators.replaceAll("(https://[^<]*)", "<a href=\"$1\">$1</a>");
        }

        String document = MessageFormat.format(credits, l10n.getString("Credits.authors"),
                l10n.getString("Credits.contributors"), l10n.getString("Credits.graphics"),
                l10n.getString("Credits.sponsors"), l10n.getString("Credits.translators"), translators,
                Links.DONATORS, l10n.getString("Credits.moreDonators"),
                MessageFormat.format(l10n.getString("Credits.packagers"), Links.DOWNLOAD));

        JTextPane tp = new JTextPane();
        tp.setContentType("text/html; charset=UTF-8");
        tp.setText(document);
        tp.setEditable(false);
        tp.setPreferredSize(new Dimension(450, 400));
        tp.setCaretPosition(0);
        //make links clickable
        tp.addHyperlinkListener(new HyperlinkListener() {
            @Override
            public void hyperlinkUpdate(final HyperlinkEvent e) {
                if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED && Desktop.isDesktopSupported()) {
                    try {
                        logger.fine("Browsing URL: " + e.getURL());
                        Desktop.getDesktop().browse(e.getURL().toURI());
                    } catch (Exception ex) {
                        logger.log(Level.SEVERE, "Can't browse hyperlink: " + e.getURL(), ex);
                    }
                }
            }
        });

        String option = l10n.getString("AboutFrame.Thank_you");
        JOptionPane op = new JOptionPane(new JScrollPane(tp), JOptionPane.INFORMATION_MESSAGE,
                JOptionPane.DEFAULT_OPTION, null, new Object[] { option }, option);
        JDialog dialog = op.createDialog(this, l10n.getString("AboutFrame.Credits"));
        dialog.setResizable(true);
        dialog.pack();
        dialog.setVisible(true);
    } catch (IOException e) {
        logger.log(Level.WARNING, "Could not show credits", e);
    }
}

From source file:dk.cubing.liveresults.uploader.engine.ResultsEngine.java

/**
 * Create preferences dialog/*from   ww  w . j  av a 2 s.  c  o m*/
 */
public void createAndShowPreferencesDialog() {
    JDialog dialog = new JDialog(frame, "Preferences");
    dialog.add(new PreferencesPanel(dialog, this));
    dialog.setResizable(false);
    dialog.pack();
    dialog.setVisible(true);
}

From source file:fr.duminy.components.swing.form.JFormPane.java

/**
 * Display this form in a dialog./*from ww  w  .  j  a v a  2s. com*/
 *
 * @param parentComponent The parent component of the dialog.
 * @return The final value entered by the user in the dialog, or null if it was cancelled.
 */
public B showDialog(Component parentComponent) {
    Window parentWindow;
    if (parentComponent == null) {
        parentWindow = JOptionPane.getRootFrame();
    } else if (parentComponent instanceof Window) {
        parentWindow = (Window) parentComponent;
    } else {
        parentWindow = SwingUtilities.getWindowAncestor(parentComponent);
    }
    final JDialog dialog = new JDialog(parentWindow, title, Dialog.ModalityType.APPLICATION_MODAL);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setContentPane(this);
    dialog.setResizable(false);
    setBorder(null);
    final MutableObject<Boolean> validated = new MutableObject<>(false);
    FormListener<B> listener = new FormListener<B>() {
        @Override
        public void formValidated(Form<B> form) {
            validated.setValue(true);
            dialog.dispose();
        }

        @Override
        public void formCancelled(Form<B> form) {
            dialog.dispose();
        }
    };

    try {
        addFormListener(listener);
        dialog.pack();
        dialog.setVisible(true);
        return validated.getValue() ? getValue() : null;
    } finally {
        removeFormListener(listener);
    }
}

From source file:biomine.bmvis2.pipeline.sources.QueryGraphSource.java

@Override
public BMGraph getBMGraph() throws GraphOperationException {
    try {/*from  ww w.  j av a2 s . co  m*/
        if (fetch == null) {
            fetch = new CrawlerFetch(query, neighborhood, database);
        }
        if (ret == null) {
            final JDialog dial = new JDialog((JFrame) null);

            dial.setTitle("BMVIS II - Query to database");
            dial.setSize(400, 200);
            dial.setMinimumSize(new Dimension(400, 200));
            dial.setResizable(false);
            final JTextArea text = new JTextArea();
            text.setEditable(false);

            dial.add(text);
            text.setText("...");

            class Z {
                Exception runExc = null;
            }

            final Z z = new Z();
            Runnable fetchThread = new Runnable() {
                public void run() {
                    try {
                        long startTime = System.currentTimeMillis();
                        while (!fetch.isDone()) {
                            fetch.update();
                            Thread.sleep(500);
                            long time = System.currentTimeMillis();
                            long elapsed = time - startTime;

                            if (elapsed > 30000) {
                                throw new GraphOperationException("Timeout while querying " + query);
                            }
                            final String newText = fetch.getState() + ":\n" + fetch.getMessages();
                            SwingUtilities.invokeLater(new Runnable() {
                                public void run() {
                                    text.setText(newText);
                                }
                            });
                        }

                        SwingUtilities.invokeAndWait(new Runnable() {
                            public void run() {
                                dial.setVisible(false);
                            }
                        });

                    } catch (Exception e) {
                        z.runExc = e;
                    }

                }

            };

            new Thread(fetchThread).start();
            dial.setModalityType(ModalityType.APPLICATION_MODAL);
            dial.setVisible(true);
            ret = fetch.getBMGraph();
            if (ret == null)
                throw new GraphOperationException(fetch.getMessages());
            if (z.runExc != null) {
                if (z.runExc instanceof GraphOperationException)
                    throw (GraphOperationException) z.runExc;
                else
                    throw new GraphOperationException(z.runExc);
            }
        }

    } catch (IOException e) {
        throw new GraphOperationException(e);
    }
    updateInfo();
    return ret;
}

From source file:com.sshtools.common.ui.OptionsPanel.java

/**
 *
 *
 * @param parent/*from   w  ww . j  a v a2  s  .  c o m*/
 * @param tabs tabs
 *
 * @return
 */
public static boolean showOptionsDialog(Component parent, OptionsTab[] tabs) {
    final OptionsPanel opts = new OptionsPanel(tabs);
    opts.reset();

    JDialog d = null;
    Window w = (Window) SwingUtilities.getAncestorOfClass(Window.class, parent);

    if (w instanceof JDialog) {
        d = new JDialog((JDialog) w, "Options", true);
    } else if (w instanceof JFrame) {
        d = new JDialog((JFrame) w, "Options", true);
    } else {
        d = new JDialog((JFrame) null, "Options", true);
    }

    final JDialog dialog = d;

    //  Create the bottom button panel
    final JButton cancel = new JButton("Cancel");
    cancel.setMnemonic('c');
    cancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            opts.cancelled = true;
            dialog.setVisible(false);
        }
    });

    final JButton ok = new JButton("Ok");
    ok.setMnemonic('o');
    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (opts.validateTabs()) {
                dialog.setVisible(false);
            }
        }
    });
    dialog.getRootPane().setDefaultButton(ok);

    JPanel buttonPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(6, 6, 0, 0);
    gbc.weighty = 1.0;
    UIUtil.jGridBagAdd(buttonPanel, ok, gbc, GridBagConstraints.RELATIVE);
    UIUtil.jGridBagAdd(buttonPanel, cancel, gbc, GridBagConstraints.REMAINDER);

    JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
    southPanel.add(buttonPanel);

    //
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    mainPanel.add(opts, BorderLayout.CENTER);
    mainPanel.add(southPanel, BorderLayout.SOUTH);

    // Show the dialog
    dialog.getContentPane().setLayout(new GridLayout(1, 1));
    dialog.getContentPane().add(mainPanel);
    dialog.pack();
    dialog.setResizable(true);
    UIUtil.positionComponent(SwingConstants.CENTER, dialog);
    dialog.setVisible(true);

    if (!opts.cancelled) {
        opts.applyTabs();
    }

    return !opts.cancelled;
}

From source file:com.brainflow.application.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);
        }/*from w ww .  ja  v  a 2  s .co  m*/
    };
    uiDefaultsCustomizer.customize(UIManager.getDefaults());

    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        public void uncaughtException(Thread t, Throwable e) {
            e.printStackTrace();
            JideOptionPane optionPane = new JideOptionPane(
                    "Click \"Details\" button to see more information ... ", JOptionPane.ERROR_MESSAGE,
                    JideOptionPane.CLOSE_OPTION);
            optionPane.setTitle("An " + e.getClass().getName() + " occurred in Brainflow : " + e.getMessage());

            JTextArea textArea = new JTextArea();
            StringWriter sw = new StringWriter();
            PrintWriter out = new PrintWriter(sw);
            e.printStackTrace(out);
            // Add string to end of text area
            textArea.append(sw.toString());
            textArea.setRows(10);
            optionPane.setDetails(new JScrollPane(textArea));
            JDialog dialog = optionPane.createDialog(brainFrame, "Warning");
            dialog.setResizable(true);
            dialog.pack();
            dialog.setVisible(true);
        }
    });

}

From source file:captureplugin.CapturePlugin.java

/**
 * Check the programs after data update.
 *///from www  .  j  av  a2 s  .co  m
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:es.emergya.ui.plugins.admin.AdminLayers.java

protected SummaryAction getSummaryAction(final CapaInformacion capaInformacion) {
    SummaryAction action = new SummaryAction(capaInformacion) {

        private static final long serialVersionUID = -3691171434904452485L;

        @Override/*from   ww  w.  j ava  2  s  .  c  o  m*/
        protected JFrame getSummaryDialog() {

            if (capaInformacion != null) {
                d = getDialog(capaInformacion, null, "", null, "image/png");
                return d;
            } else {
                JDialog primera = getJDialog();
                primera.setResizable(false);
                primera.setVisible(true);
                primera.setAlwaysOnTop(true);
            }
            return null;
        }

        private JDialog getJDialog() {
            final JDialog dialog = new JDialog();
            dialog.setTitle(i18n.getString("admin.capas.nueva.titleBar"));
            dialog.setIconImage(getBasicWindow().getIconImage());

            dialog.setLayout(new BorderLayout());

            JPanel centro = new JPanel(new FlowLayout());
            centro.setOpaque(false);
            JLabel label = new JLabel(i18n.getString("admin.capas.nueva.url"));
            final JTextField url = new JTextField(50);
            final JLabel icono = new JLabel(LogicConstants.getIcon("48x48_transparente"));
            label.setLabelFor(url);
            centro.add(label);
            centro.add(url);
            centro.add(icono);
            dialog.add(centro, BorderLayout.CENTER);

            JPanel pie = new JPanel(new FlowLayout(FlowLayout.TRAILING));
            pie.setOpaque(false);
            final JButton siguiente = new JButton(i18n.getString("admin.capas.nueva.boton.siguiente"),
                    LogicConstants.getIcon("button_next"));
            JButton cancelar = new JButton(i18n.getString("admin.capas.nueva.boton.cancelar"),
                    LogicConstants.getIcon("button_cancel"));
            final SiguienteActionListener siguienteActionListener = new SiguienteActionListener(url, dialog,
                    icono, siguiente);
            url.addActionListener(siguienteActionListener);

            siguiente.addActionListener(siguienteActionListener);

            cancelar.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    dialog.dispose();
                }
            });
            pie.add(siguiente);
            pie.add(cancelar);
            dialog.add(pie, BorderLayout.SOUTH);

            dialog.getContentPane().setBackground(Color.WHITE);

            dialog.pack();
            dialog.setLocationRelativeTo(null);
            return dialog;
        }

        private JFrame getDialog(final CapaInformacion c, final Capa[] left_items, final String service,
                final Map<String, Boolean> transparentes, final String png) {

            if (left_items != null && left_items.length == 0) {
                JOptionPane.showMessageDialog(AdminLayers.this,
                        i18n.getString("admin.capas.nueva.error.noCapasEnServicio"));
            } else {

                final String label_cabecera = i18n.getString("admin.capas.nueva.nombreCapa");
                final String label_pie = i18n.getString("admin.capas.nueva.infoAdicional");
                final String centered_label = i18n.getString("admin.capas.nueva.origenDatos");
                final String left_label = i18n.getString("admin.capas.nueva.subcapasDisponibles");
                final String right_label;
                if (left_items != null) {
                    right_label = i18n.getString("admin.capas.nueva.capasSeleccionadas");
                } else {
                    right_label = i18n.getString("admin.capas.ficha.capasSeleccionadas");
                }
                final String tituloVentana, cabecera;
                if (c.getNombre() == null) {
                    tituloVentana = i18n.getString("admin.capas.nueva.titulo.nuevaCapa");
                    cabecera = i18n.getString("admin.capas.nueva.cabecera.nuevaCapa");
                } else {
                    tituloVentana = i18n.getString("admin.capas.nueva.titulo.ficha");
                    cabecera = i18n.getString("admin.capas.nueva.cabecera.ficha");
                }

                final Capa[] right_items = c.getCapas().toArray(new Capa[0]);
                final AdminPanel.SaveOrUpdateAction<CapaInformacion> guardar = layers.new SaveOrUpdateAction<CapaInformacion>(
                        c) {

                    private static final long serialVersionUID = 7447770296943341404L;

                    @Override
                    public void actionPerformed(ActionEvent e) {

                        if (isNew && CapaConsultas.alreadyExists(textfieldCabecera.getText())) {
                            JOptionPane.showMessageDialog(super.frame,
                                    i18n.getString("admin.capas.nueva.error.nombreCapaYaExiste"));

                        } else if (textfieldCabecera.getText().isEmpty()) {
                            JOptionPane.showMessageDialog(super.frame,
                                    i18n.getString("admin.capas.nueva.error.nombreCapaEnBlanco"));

                        } else if (((DefaultListModel) right.getModel()).size() == 0) {
                            JOptionPane.showMessageDialog(super.frame,
                                    i18n.getString("admin.capas.nueva.error.noCapasSeleccionadas"));

                        } else if (cambios) {
                            int i = JOptionPane.showConfirmDialog(super.frame,
                                    i18n.getString("admin.capas.nueva.confirmar.guardar.titulo"),
                                    i18n.getString("admin.capas.nueva.confirmar.boton.guardar"),
                                    JOptionPane.YES_NO_CANCEL_OPTION);

                            if (i == JOptionPane.YES_OPTION) {

                                if (original == null) {
                                    original = new CapaInformacion();

                                }
                                original.setInfoAdicional(textfieldPie.getText());
                                original.setNombre(textfieldCabecera.getText());
                                original.setHabilitada(habilitado.isSelected());
                                original.setOpcional(comboTipoCapa.getSelectedIndex() != 0);

                                boolean transparente = true;

                                HashSet<Capa> capas = new HashSet<Capa>();
                                List<Capa> capasEnOrdenSeleccionado = new ArrayList<Capa>();
                                int indice = 0;
                                for (Object c : ((DefaultListModel) right.getModel()).toArray()) {
                                    if (c instanceof Capa) {
                                        transparente = transparente && (transparentes != null
                                                && transparentes.get(((Capa) c).getNombre()) != null
                                                && transparentes.get(((Capa) c).getNombre()));
                                        capas.add((Capa) c);
                                        capasEnOrdenSeleccionado.add((Capa) c);
                                        ((Capa) c).setCapaInformacion(original);
                                        ((Capa) c).setOrden(indice++);
                                        // ((Capa)
                                        // c).setNombre(c.toString());
                                    }

                                }
                                original.setCapas(capas);

                                if (original.getId() == null) {
                                    String url = nombre.getText();

                                    if (url.indexOf("?") > -1) {
                                        if (!url.endsWith("?")) {
                                            url += "&";

                                        }
                                    } else {
                                        url += "?";

                                    }
                                    url += "VERSION=" + version + "&REQUEST=GetMap&FORMAT=" + png + "&SERVICE="
                                            + service + "&WIDTH={2}&HEIGHT={3}&BBOX={1}&SRS={0}";
                                    // if (transparente)
                                    url += "&TRANSPARENT=TRUE";
                                    url += "&LAYERS=";

                                    String estilos = "";
                                    final String coma = "%2C";
                                    if (capasEnOrdenSeleccionado.size() > 0) {
                                        for (Capa c : capasEnOrdenSeleccionado) {
                                            url += c.getTitulo().replaceAll(" ", "+") + coma;
                                            estilos += c.getEstilo() + coma;
                                        }
                                        estilos = estilos.substring(0, estilos.length() - coma.length());

                                        estilos = estilos.replaceAll(" ", "+");

                                        url = url.substring(0, url.length() - coma.length());
                                    }
                                    url += "&STYLES=" + estilos;
                                    original.setUrl_visible(original.getUrl());
                                    original.setUrl(url);
                                }
                                CapaInformacionAdmin.saveOrUpdate(original);

                                cambios = false;

                                layers.setTableData(getAll(new CapaInformacion()));

                                closeFrame();
                            } else if (i == JOptionPane.NO_OPTION) {
                                closeFrame();

                            }
                        } else {
                            closeFrame();

                        }
                    }
                };
                JFrame segunda = generateUrlDialog(label_cabecera, label_pie, centered_label, tituloVentana,
                        left_items, right_items, left_label, right_label, guardar,
                        LogicConstants.getIcon("tittleficha_icon_capa"), cabecera, c.getHabilitada(),
                        c.getOpcional(), c.getUrl_visible());
                segunda.setResizable(false);

                if (c != null) {
                    textfieldCabecera.setText(c.getNombre());
                    textfieldPie.setText(c.getInfoAdicional());
                    nombre.setText(c.getUrl_visible());
                    nombre.setEditable(false);
                    if (c.getHabilitada() == null) {
                        c.setHabilitada(false);

                    }
                    habilitado.setSelected(c.getHabilitada());
                    if (c.isOpcional() != null && c.isOpcional()) {
                        comboTipoCapa.setSelectedIndex(1);
                    } else {
                        comboTipoCapa.setSelectedIndex(0);
                    }
                }

                if (c.getId() == null) {
                    habilitado.setSelected(true);
                    comboTipoCapa.setSelectedIndex(1);
                }

                habilitado.setEnabled(true);
                if (c == null || c.getId() == null) {
                    textfieldCabecera.setEditable(true);
                } else {
                    textfieldCabecera.setEditable(false);
                }

                cambios = false;

                segunda.pack();
                segunda.setLocationRelativeTo(null);
                segunda.setVisible(true);
                return segunda;
            }
            return null;
        }

        class SiguienteActionListener implements ActionListener {

            private final JTextField url;
            private final JDialog dialog;
            private final JLabel icono;
            private final JButton siguiente;

            public SiguienteActionListener(JTextField url, JDialog dialog, JLabel icono, JButton siguiente) {
                this.url = url;
                this.dialog = dialog;
                this.icono = icono;
                this.siguiente = siguiente;
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                final CapaInformacion ci = new CapaInformacion();
                ci.setUrl(url.getText());
                ci.setCapas(new HashSet<Capa>());
                SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() {

                    private List<Capa> res = new LinkedList<Capa>();
                    private String service = "WMS";
                    private String png = null;
                    private Map<String, Boolean> transparentes = new HashMap<String, Boolean>();
                    private ArrayList<String> errorStack = new ArrayList<String>();
                    private Boolean goOn = true;

                    @SuppressWarnings(value = "unchecked")
                    @Override
                    protected Object doInBackground() throws Exception {
                        try {
                            final String url2 = ci.getUrl();
                            WMSClient client = new WMSClient(url2);
                            client.connect(new ICancellable() {

                                @Override
                                public boolean isCanceled() {
                                    return false;
                                }

                                @Override
                                public Object getID() {
                                    return System.currentTimeMillis();
                                }
                            });

                            version = client.getVersion();

                            for (final String s : client.getLayerNames()) {
                                WMSLayer layer = client.getLayer(s);
                                // this.service =
                                // client.getServiceName();
                                final Vector allSrs = layer.getAllSrs();
                                boolean epsg = (allSrs != null) ? allSrs.contains("EPSG:4326") : false;
                                final Vector formats = client.getFormats();
                                if (formats.contains("image/png")) {
                                    png = "image/png";
                                } else if (formats.contains("IMAGE/PNG")) {
                                    png = "IMAGE/PNG";
                                } else if (formats.contains("png")) {
                                    png = "png";
                                } else if (formats.contains("PNG")) {
                                    png = "PNG";
                                }
                                boolean image = png != null;
                                if (png == null) {
                                    png = "IMAGE/PNG";
                                }
                                if (epsg && image) {
                                    boolean hasTransparency = layer.hasTransparency();
                                    this.transparentes.put(s, hasTransparency);
                                    Capa capa = new Capa();
                                    capa.setCapaInformacion(ci);
                                    if (layer.getStyles().size() > 0) {
                                        capa.setEstilo(((WMSStyle) layer.getStyles().get(0)).getName());
                                    }
                                    capa.setNombre(layer.getTitle());
                                    capa.setTitulo(s);
                                    res.add(capa);
                                    if (!hasTransparency) {
                                        errorStack.add(i18n.getString(Locale.ROOT,
                                                "admin.capas.nueva.error.capaNoTransparente",
                                                layer.getTitle()));
                                    }
                                } else {
                                    String error = "";
                                    // if (opaque)
                                    // error += "<li>Es opaca</li>";
                                    if (!image) {
                                        error += i18n.getString("admin.capas.nueva.error.formatoPNG");
                                    }
                                    if (!epsg) {
                                        error += i18n.getString("admin.capas.nueva.error.projeccion");
                                    }
                                    final String cadena = i18n.getString(Locale.ROOT,
                                            "admin.capas.nueva.error.errorCapa", new Object[] { s, error });
                                    errorStack.add(cadena);
                                }
                            }
                        } catch (final Throwable t) {
                            log.error("Error al parsear el WMS", t);
                            goOn = false;
                            icono.setIcon(LogicConstants.getIcon("48x48_transparente"));

                            JOptionPane.showMessageDialog(dialog,
                                    i18n.getString("admin.capas.nueva.error.errorParseoWMS"));

                            siguiente.setEnabled(true);
                        }
                        return null;
                    }

                    @Override
                    protected void done() {
                        super.done();
                        if (goOn) {

                            dialog.dispose();
                            ci.setUrl_visible(ci.getUrl());
                            final JFrame frame = getDialog(ci, res.toArray(new Capa[0]), service, transparentes,
                                    png);
                            if (!errorStack.isEmpty()) {
                                String error = "<html>";
                                for (final String s : errorStack) {
                                    error += s + "<br/>";
                                }
                                error += "</html>";
                                final String errorString = error;
                                SwingUtilities.invokeLater(new Runnable() {

                                    @Override
                                    public void run() {
                                        JOptionPane.showMessageDialog(frame, errorString);
                                    }
                                });
                            }
                        }
                    }
                };
                sw.execute();
                icono.setIcon(LogicConstants.getIcon("anim_conectando"));
                icono.repaint();
                siguiente.setEnabled(false);
            }
        }
    };

    return action;
}

From source file:IHM.GialogGraph.java

public void Show() {
    VisualizationViewer<String, String> vv;
    vv = new VisualizationViewer<>(new CircleLayout<String, String>(JungGraph), dim);

    Transformer<String, String> transformer = new Transformer<String, String>() {
        @Override/*ww  w . ja  v a  2s .  c  o m*/
        public String transform(String arg0) {
            return arg0;
        }
    };
    vv.getRenderContext().setVertexLabelTransformer(transformer);
    transformer = new Transformer<String, String>() {
        @Override
        public String transform(String arg0) {
            return arg0;
        }
    };
    vv.getRenderContext().setEdgeLabelTransformer(transformer);
    vv.getRenderer().setVertexRenderer(new MyRenderer());
    DefaultModalGraphMouse<String, Number> graphMouse = new DefaultModalGraphMouse<String, Number>();
    vv.setGraphMouse(graphMouse);
    graphMouse.setMode(ModalGraphMouse.Mode.PICKING);

    JDialog frame = new JDialog(MymainWidow);
    frame.getContentPane().add(vv);
    frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    frame.addWindowListener(new WindowListener() {

        @Override
        public void windowOpened(WindowEvent e) {

        }

        @Override
        public void windowClosing(WindowEvent e) {
            MymainWidow.enable();
        }

        @Override
        public void windowClosed(WindowEvent e) {
            MymainWidow.enable();
        }

        @Override
        public void windowIconified(WindowEvent e) {

        }

        @Override
        public void windowDeiconified(WindowEvent e) {

        }

        @Override
        public void windowActivated(WindowEvent e) {

        }

        @Override
        public void windowDeactivated(WindowEvent e) {

        }
    });
    frame.pack();
    frame.setLocationRelativeTo(MymainWidow);
    frame.setResizable(true);
    frame.setVisible(true);
}

From source file:net.sourceforge.processdash.ev.ui.ScheduleBalancingDialog.java

private void buildAndShowGUI() {
    chartData = null;/*  ww  w .  j  av  a  2  s .  c o  m*/
    int numScheduleRows = scheduleRows.size();

    sumUpTotalTime();
    originalTotalTime = totalRow.time;
    if (originalTotalTime == 0)
        // if the rows added up to zero, choose a nominal target total time
        // corresponding to 10 hours per included schedule
        originalTotalTime = numScheduleRows * 60 * 10;

    JPanel panel = new JPanel(new GridBagLayout());
    if (numScheduleRows == 1) {
        totalRow.rowLabel = scheduleRows.get(0).rowLabel;
    } else {
        for (int i = 0; i < numScheduleRows; i++)
            scheduleRows.get(i).addToPanel(panel, i);
        scheduleRows.get(numScheduleRows - 1).showPercentageTickMarks();
        addChartToPanel(panel, numScheduleRows + 1);
    }
    totalRow.addToPanel(panel, numScheduleRows);

    if (rowsAreEditable == false) {
        String title = TaskScheduleDialog.resources.getString("Balance.Read_Only_Title");
        JOptionPane.showMessageDialog(parent.frame, panel, title, JOptionPane.PLAIN_MESSAGE);

    } else {
        String title = TaskScheduleDialog.resources.getString("Balance.Editable_Title");
        JDialog dialog = new JDialog(parent.frame, title, true);
        addButtons(dialog, panel, numScheduleRows + 2);
        panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
        dialog.getContentPane().add(panel);
        dialog.pack();
        dialog.setLocationRelativeTo(parent.frame);
        dialog.setResizable(true);
        dialog.setVisible(true);
    }
}