Example usage for javax.swing JDialog getContentPane

List of usage examples for javax.swing JDialog getContentPane

Introduction

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

Prototype

public Container getContentPane() 

Source Link

Document

Returns the contentPane object for this dialog.

Usage

From source file:org.cytoscape.dyn.internal.graphMetrics.GraphMetricsResultsPanel.java

/**
 * //from   w w  w  .ja  va 2 s  .  co  m
 */
public void enlargeChart() {
    chartPanelForDialog = new ChartPanel(this.timeSeries);
    JDialog dialog = new JDialog(cyActivator.getCySwingAppication().getJFrame(), "Dynamic Graph Metrics",
            false);
    dialog.getContentPane().add(chartPanelForDialog);
    dialog.pack();
    dialog.setLocationRelativeTo(cyActivator.getCySwingAppication().getJFrame());
    dialog.setVisible(true);
}

From source file:net.automatalib.visualization.jung.JungGraphVisualizationProvider.java

@Override
public <N, E> void visualize(Graph<N, E> graph, GraphDOTHelper<N, ? super E> helper, boolean modal,
        Map<String, String> options) {

    DirectedGraph<NodeVisualization, EdgeVisualization> visGraph = createVisualizationGraph(graph, helper);

    Layout<NodeVisualization, EdgeVisualization> layout = new KKLayout<>(visGraph);

    VisualizationViewer<NodeVisualization, EdgeVisualization> vv = new VisualizationViewer<>(layout);
    setupRenderContext(vv.getRenderContext());
    vv.setGraphMouse(mouse);/*from   w w  w  . ja va  2 s.  c om*/

    final JDialog frame = new JDialog((Dialog) null, "Visualization", modal);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.getContentPane().add(vv);
    frame.pack();
    frame.setVisible(true);
}

From source file:kenh.xscript.elements.Debug.java

/**
 * a dialog use to debug./*from ww  w. j a va  2  s.  c  o  m*/
 */
public void process() {

    JDialog dialog = new JDialog((Frame) null, true);
    dialog.setTitle("Debugger");
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    dialog.setSize(750, 200);
    initial(dialog.getContentPane());
    dialog.setVisible(true);

    this.result = null;

}

From source file:king.flow.action.business.InsertCardAction.java

@Override
protected void installButtonAction() {
    JButton btn = (JButton) this.owner;
    btn.addActionListener(new ActionListener() {

        @Override//from w ww  .j a  v a  2s  . c o  m
        public void actionPerformed(ActionEvent e) {
            if (cardType == DeviceEnum.GZ_CARD) {
                progressTip = new JLabel(
                        getResourceMsg("operation.ic.card.insert.prompt" + "." + DeviceEnum.GZ_CARD.value()));
            } else {
                progressTip = new JLabel(getResourceMsg("operation.ic.card.insert.prompt"));
            }

            Window windowNode = getWindowNode();
            UiStyle uiStyle = windowNode.getUiStyle();
            if (uiStyle != null && uiStyle.getFont() != null && uiStyle.getFont().getName() != null) {
                progressTip.setFont(new FontUIResource(uiStyle.getFont().getName(), java.awt.Font.BOLD, 50));
            } else {
                progressTip.setFont(new FontUIResource("Dialog", java.awt.Font.BOLD, 50));
            }
            progressTip.setHorizontalAlignment(SwingConstants.CENTER);
            progressTip.setVerticalAlignment(SwingConstants.BOTTOM);
            final JDialog progressAnimation = buildAnimationDialog(animationFile);
            progressTip.setBounds(0, 120, progressAnimation.getBounds().width, 80);
            progressAnimation.getContentPane().add(progressTip, 1);
            final ImageIcon bgImage = CommonUtil.getImageIcon("/image/2.jpg");
            //final ImageIcon bgImage = CommonUtil.getDefaultBackgroundImage();
            if (bgImage != null) {
                progressAnimation.getContentPane().add(new JLabel(bgImage), 2);
            } else {
                progressAnimation.getContentPane().add(new JLabel(), 2);
            }

            switch (cardType) {
            case GZ_CARD:
                waitCommunicationTask(new GZReadCardTask(), progressAnimation);
                break;
            default:
                getLogger(InsertCardAction.class.getName()).log(Level.WARNING,
                        "Unsupported card type[{0}] for InsertCardAction", cardType.name());
                handleErr(getResourceMsg(GzCardConductor.GUOZHEN_CARD_OPERATION_PROMPT));
            }
        }
    });
}

From source file:com.aw.swing.mvp.view.IPView.java

/**
 * Get the components of the viewSrc//from www  .j a v a2s.  c om
 *
 * @return
 */
public Component[] getJComponents() {
    if (viewSrc instanceof JDialog) {
        JDialog dlg = (JDialog) viewSrc;
        return dlg.getContentPane().getComponents();
    } else {
        JPanel pnl = (JPanel) AttributeAccessor.get(viewSrc, "pnlMain");
        return pnl.getComponents();
    }
}

From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.ChartDisplayPanel.java

/**
 * Creates a dialog window which contains the chart in its preferred size.
 *//*  ww  w.ja v  a  2 s .  c  o  m*/
private void displayEnlarged() {
    JDialog dialog = new JDialog(ownerDialog, visualizer.getTitle(), false);
    dialog.getContentPane().add(JFreeChartConn.createPanel(chart));
    dialog.pack();
    dialog.setLocationRelativeTo(ownerDialog);
    dialog.setVisible(true);
}

From source file:emailplugin.MailCreator.java

/**
 * Gives the User the opportunity to specify which Desktop he uses (KDE or
 * Gnome)/*from  w ww.java  2  s.  c om*/
 *
 * @param parent
 *          Parent Dialog
 * @return true if KDE or Gnome has been selected, false if the User wanted to
 *         specify the App
 */
private boolean showKdeGnomeDialog(Frame parent) {
    final JDialog dialog = new JDialog(parent, true);

    dialog.setTitle(mLocalizer.msg("chooseTitle", "Choose"));

    JPanel panel = (JPanel) dialog.getContentPane();
    panel.setLayout(new FormLayout("10dlu, fill:pref:grow",
            "default, 3dlu, default, 3dlu, default, 3dlu, default, 3dlu:grow, default"));
    panel.setBorder(Borders.DIALOG_BORDER);

    CellConstraints cc = new CellConstraints();

    panel.add(UiUtilities.createHelpTextArea(mLocalizer.msg("cantConfigure", "Can't configure on your system")),
            cc.xyw(1, 1, 2));

    JRadioButton kdeButton = new JRadioButton(mLocalizer.msg("kde", "I am using KDE"));
    panel.add(kdeButton, cc.xy(2, 3));

    JRadioButton gnomeButton = new JRadioButton(mLocalizer.msg("gnome", "I am using Gnome"));
    panel.add(gnomeButton, cc.xy(2, 5));

    JRadioButton selfButton = new JRadioButton(mLocalizer.msg("self", "I want to configure by myself"));
    panel.add(selfButton, cc.xy(2, 7));

    ButtonGroup group = new ButtonGroup();
    group.add(kdeButton);
    group.add(gnomeButton);
    group.add(selfButton);

    selfButton.setSelected(true);

    JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK));
    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
        }
    });

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    buttonPanel.add(ok);
    panel.add(buttonPanel, cc.xy(2, 9));

    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);

    if (kdeButton.isSelected()) {
        mSettings.setApplication("kfmclient");
        mSettings.setParameter("exec {content}");
    } else if (gnomeButton.isSelected()) {
        mSettings.setApplication("gnome-open");
        mSettings.setParameter("{content}");
    } else {
        Plugin.getPluginManager().showSettings(mPlugin);
        return false;
    }

    return true;
}

From source file:emailplugin.MailCreator.java

/**
 * Show the EMail-Open Dialog./*w ww .j  a  v a  2  s .  c om*/
 *
 * 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:de.codesourcery.jasm16.ide.ui.utils.UIUtils.java

public static JDialog createMessageDialog(Window parent, String title, String msg) {

    final JDialog dialog = new JDialog(parent, title);

    final JTextArea message = createMultiLineLabel(msg);

    final JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout());

    final JPanel messagePanel = new JPanel();
    messagePanel.setLayout(new GridBagLayout());

    GridBagConstraints cnstrs = constraints(0, 0, true, false, GridBagConstraints.NONE);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 0;/* w  w w .j  a  va 2s.c  om*/
    cnstrs.gridheight = 1;
    messagePanel.add(message, cnstrs);

    final JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());

    cnstrs = constraints(0, 0, true, false, GridBagConstraints.NONE);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridheight = 1;
    cnstrs.weighty = 0;
    cnstrs.insets = new Insets(5, 2, 5, 2); // top,left,bottom,right         
    panel.add(messagePanel, cnstrs);

    cnstrs = constraints(0, 1, true, true, GridBagConstraints.HORIZONTAL);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridheight = 1;
    cnstrs.weighty = 0;
    cnstrs.insets = new Insets(0, 2, 10, 2); // top,left,bottom,right      
    panel.add(buttonPanel, cnstrs);

    dialog.getContentPane().add(panel);
    dialog.pack();
    return dialog;
}

From source file:Main.java

public static boolean showModalDialogOnEDT(JComponent contents, String title, String okButtonMessage,
        String cancelButtonMessage, ModalityType modalityType, final boolean systemExitOnDisposed) {

    class Result {
        boolean OK = false;
    }/*w ww. jav a2  s .c  om*/
    final Result result = new Result();

    final JDialog dialog = new JDialog((Frame) null, title, true) {
        @Override
        public void dispose() {
            super.dispose();
            if (systemExitOnDisposed) {
                System.exit(0);
            }
        }
    };

    // ensure it doesn't block other dialogs
    if (modalityType != null) {
        dialog.setModalityType(modalityType);
    }

    // See http://stackoverflow.com/questions/1343542/how-do-i-close-a-jdialog-and-have-the-window-event-listeners-be-notified
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
    if (okButtonMessage != null) {
        buttonPane.add(new JButton(new AbstractAction(okButtonMessage) {

            @Override
            public void actionPerformed(ActionEvent e) {
                result.OK = true;
                dialog.dispose();
            }
        }));
    }

    if (cancelButtonMessage != null) {
        buttonPane.add(new JButton(new AbstractAction(cancelButtonMessage) {

            @Override
            public void actionPerformed(ActionEvent e) {
                dialog.dispose();
            }
        }));
    }

    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel.setLayout(new BorderLayout());
    panel.add(contents, BorderLayout.CENTER);
    panel.add(buttonPane, BorderLayout.SOUTH);

    // startup frame
    dialog.getContentPane().add(panel);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.pack();

    // This hopefully centres the dialog even though the parameter is null 
    // see http://stackoverflow.com/questions/213266/how-do-i-center-a-jdialog-on-screen
    dialog.setLocationRelativeTo(null);
    dialog.setVisible(true);

    return result.OK;
}