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:Main.java

    public static void main(String[] args) {
  JOptionPane pane = new JOptionPane("JOptionPane",
      JOptionPane.INFORMATION_MESSAGE);
  String dialogTitle = "Resizable Custom Dialog";
  JDialog dialog = pane.createDialog(dialogTitle);
  dialog.setResizable(true);
  dialog.setVisible(true);//  w w w  . ja v  a 2s .  com

}

From source file:Main.java

public static void showDialog(JDialog dlg, Component parent, boolean resizable) {
    dlg.setResizable(resizable);
    dlg.pack();/*from w ww.  j a  v  a  2  s  . co  m*/
    dlg.setLocationRelativeTo(parent);
    dlg.setVisible(true);
}

From source file:Main.java

public static void showModalDialog(JDialog dlg, Component parent, boolean resizable) {
    dlg.setResizable(resizable);
    dlg.setModal(true);//  w w w  .j av  a2s .c o  m
    dlg.pack();
    dlg.setLocationRelativeTo(parent);
    dlg.setVisible(true);
}

From source file:Main.java

/**
 * Initialises the {@link JDialog} for the {@link JComponent}.
 * //from   w w  w  . j  av  a  2 s . c  o  m
 * @param dialog
 * @param component
 * @param parentComponent
 */
private static void initDialog(final JDialog dialog, final JComponent component,
        final Component parentComponent) {
    dialog.setResizable(true);
    dialog.setComponentOrientation(component.getComponentOrientation());
    Container contentPane = dialog.getContentPane();

    contentPane.setLayout(new BorderLayout());
    contentPane.add(component, BorderLayout.CENTER);

    final int buttonWidth = 75;

    final JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(2, 4, 4, 4));

    buttonPanel.add(Box.createHorizontalGlue());

    @SuppressWarnings("serial")
    final Action closeAction = new AbstractAction("Close") {
        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
        }
    };

    final JButton button = new JButton(closeAction);
    fixWidth(button, buttonWidth);
    buttonPanel.add(button);

    contentPane.add(buttonPanel, BorderLayout.SOUTH);

    if (JDialog.isDefaultLookAndFeelDecorated()) {
        boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations();
        if (supportsWindowDecorations) {
            dialog.setUndecorated(true);
            component.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
        }
    }
    dialog.pack();
    dialog.setLocationRelativeTo(parentComponent);
    WindowAdapter adapter = new WindowAdapter() {
        //         private boolean gotFocus = false;
        public void windowClosing(WindowEvent we) {
            fireAction(we.getSource(), closeAction, "close");
        }
    };
    dialog.addWindowListener(adapter);
    dialog.addWindowFocusListener(adapter);
}

From source file:ModifiableJOptionPane.java

/**
 * @see javax.swing.JOptionPane#createDialog(java.awt.Component, java.lang.String)
 *//*w w w. j a  v a2 s  .c o m*/
public JDialog createDialog(Component parentComponent, String title) throws HeadlessException {
    JDialog dialog = super.createDialog(parentComponent, title);
    dialog.setResizable(isResizable());
    return dialog;
}

From source file:org.pgptool.gui.ui.importkey.KeyImporterView.java

@Override
protected JDialog initDialog(Window owner, Object constraints) {
    JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
    ret.setLayout(new BorderLayout());
    ret.setResizable(true);
    ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    ret.setTitle(Messages.get("action.importKey"));
    ret.add(pnl, BorderLayout.CENTER);
    ret.setMinimumSize(new Dimension(spacing(60), spacing(30)));

    initWindowGeometryPersister(ret, "keyImprt");

    return ret;/*from ww w.j a  va  2  s  .  c o  m*/
}

From source file:org.pgptool.gui.ui.keyslist.KeysListView.java

@Override
protected JDialog initDialog(Window owner, Object constraints) {
    JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
    ret.setMinimumSize(new Dimension(spacing(50), spacing(25)));
    ret.setLayout(new BorderLayout());
    ret.setResizable(true);
    ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    ret.setTitle(Messages.get("term.keysList"));
    ret.add(panelRoot, BorderLayout.CENTER);
    ret.setJMenuBar(menuBar);/*from w w  w .j  a v  a  2  s  .com*/
    initWindowGeometryPersister(ret, "keysList");
    return ret;
}

From source file:com.digitalgeneralists.assurance.ui.factories.DialogFactory.java

public JDialog createFileAttributesDialogInstance(Window parent, ModalityType modality,
        IDialogResponseHandler responseHandler, FileReference file) {
    FileAttributesPanel fileAttributesPanel = this.factory.getBean(FileAttributesPanel.class);

    fileAttributesPanel.setFileReference(file);

    JDialog scanDefinitionDialog = createDialogInstance(parent, modality, responseHandler, fileAttributesPanel,
            new Dimension(600, 600));
    scanDefinitionDialog.setResizable(true);
    return scanDefinitionDialog;
}

From source file:com.digitalgeneralists.assurance.ui.factories.DialogFactory.java

public JDialog createAboutDialogInstance(Window parent, ModalityType modality,
        IDialogResponseHandler responseHandler) {
    AboutPanel aboutApplicationPanel = this.factory.getBean(AboutPanel.class);

    JDialog aboutApplicationDialog = createDialogInstance(parent, modality, responseHandler,
            aboutApplicationPanel, new Dimension(300, 200));
    aboutApplicationDialog.setResizable(false);
    return aboutApplicationDialog;
}

From source file:esmska.gui.AboutFrame.java

private void licenseButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_licenseButtonActionPerformed
    //show licence
    try {/*w w  w .  j  a  v a 2  s . com*/
        logger.fine("Showing license...");
        String license = IOUtils.toString(getClass().getResourceAsStream(RES + "license.txt"), "UTF-8");
        final String agpl = IOUtils.toString(getClass().getResourceAsStream(RES + "gnu-agpl.txt"), "UTF-8");
        license = MiscUtils.escapeHtml(license);
        license = license.replaceAll("GNU Affero General Public License",
                "<a href=\"agpl\">GNU Affero General Public License</a>");

        final JTextPane tp = new JTextPane();
        tp.setContentType("text/html; charset=UTF-8");
        tp.setText("<html><pre>" + license + "</pre></html>");
        tp.setEditable(false);
        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        tp.setPreferredSize(new Dimension((int) d.getWidth() / 2, (int) d.getHeight() / 2)); //reasonable size
        tp.setCaretPosition(0);
        //make links clickable
        tp.addHyperlinkListener(new HyperlinkListener() {
            @Override
            public void hyperlinkUpdate(final HyperlinkEvent e) {
                if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                    logger.fine("Showing GNU AGPL...");
                    tp.setText(null);
                    tp.setContentType("text/plain");
                    tp.setText(agpl);
                    tp.setCaretPosition(0);
                }
            }
        });

        String option = l10n.getString("AboutFrame.Acknowledge");
        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.License"));
        dialog.setResizable(true);
        dialog.pack();
        dialog.setVisible(true);
    } catch (IOException ex) {
        logger.log(Level.WARNING, "Could not show license", ex);
    }
}