Java Code Examples for javax.swing.JDialog#getContentPane()

The following examples show how to use javax.swing.JDialog#getContentPane() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Help.java    From FancyBing with GNU General Public License v3.0 5 votes vote down vote up
public Help(URL contents, MessageDialogs messageDialogs,
            String title)
{
    m_messageDialogs = messageDialogs;
    m_contents = contents;
    Container contentPane;
    if (Platform.isMac())
    {
        JDialog dialog = new JDialog((Frame)null, title);
        contentPane = dialog.getContentPane();
        m_window = dialog;
    }
    else
    {
        JFrame frame = new JFrame(title);
        GuiUtil.setGoIcon(frame);
        contentPane = frame.getContentPane();
        m_window = frame;
    }
    JPanel panel = new JPanel(new BorderLayout());
    contentPane.add(panel);
    panel.add(createButtons(), BorderLayout.NORTH);
    m_editorPane = new JEditorPane();
    m_editorPane.setEditable(false);
    m_editorPane.addHyperlinkListener(this);
    int width = GuiUtil.getDefaultMonoFontSize() * 50;
    int height = GuiUtil.getDefaultMonoFontSize() * 60;
    JScrollPane scrollPane =
        new JScrollPane(m_editorPane,
                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                        JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    if (Platform.isMac())
        // Default Apple L&F uses no border, but Quaqua 3.7.4 does
        scrollPane.setBorder(null);
    scrollPane.setPreferredSize(new Dimension(width, height));
    panel.add(scrollPane, BorderLayout.CENTER);
    m_window.pack();
    loadURL(m_contents);
    appendHistory(m_contents);
}
 
Example 2
Source File: DeprecationWarning.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Wraps the content pane of the dialog with this instance
 *
 * @param dialog
 * 		a fully configured dialog
 */
public void addToDialog(JDialog dialog) {
	if (!(dialog.getContentPane() instanceof DeprecationWarning) && originalContentPane == null) {
		originalContentPane = dialog.getContentPane();
		add(originalContentPane, BorderLayout.CENTER);
		dialog.setContentPane(this);
	}
}
 
Example 3
Source File: DialogUtils.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Centers the dialog over the given parent component. Also, creates a
 * semi-transparent panel behind the dialog to mask the parent content.
 * The title of the dialog is displayed in a custom fashion over the dialog
 * panel, and a rectangular shadow is placed behind the dialog.
 */
public static void createDialogBackPanel(JDialog dialog, Component parent) {
	dialog.setBackground(new Color(255, 255, 255, 64));
	
	DialogBackPanel newContentPane = new DialogBackPanel(dialog.getContentPane(), dialog.getTitle());
	dialog.setContentPane(newContentPane);
	dialog.setSize(parent.getSize());
	dialog.setLocation(parent.getLocationOnScreen());
}
 
Example 4
Source File: SwingDemo.java    From treelayout with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void showInDialog(JComponent panel) {
	JDialog dialog = new JDialog();
	Container contentPane = dialog.getContentPane();
	((JComponent) contentPane).setBorder(BorderFactory.createEmptyBorder(
			10, 10, 10, 10));
	contentPane.add(panel);
	dialog.pack();
	dialog.setLocationRelativeTo(null);
	dialog.setVisible(true);
}
 
Example 5
Source File: AbstractModalDialog.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
protected void setEnabledComponentsWhileLoading(boolean enabled) {
    JDialog dialog = getJDialog();
    JPanel dialogContentPanel = (JPanel)dialog.getContentPane();

    Stack<JComponent> stack = new Stack<JComponent>();
    stack.push(dialogContentPanel);
    while (!stack.isEmpty()) {
        JComponent component = stack.pop();
        component.setEnabled(enabled);
        int childrenCount = component.getComponentCount();
        for (int i=0; i<childrenCount; i++) {
            Component child = component.getComponent(i);
            if (child instanceof JComponent) {
                JComponent childComponent = (JComponent) child;
                boolean found = false;
                for (int k=0; k<this.componentsAllwaysEnabled.size(); k++) {
                    if (childComponent == this.componentsAllwaysEnabled.get(k)) {
                        found = true;
                    }
                }
                if (!found) {
                    // add the component in the stack to be enabled/disabled
                    stack.push(childComponent);
                }
            }
        }
    }
}
 
Example 6
Source File: LibraryUpdater.java    From gcs with Mozilla Public License 2.0 4 votes vote down vote up
public static final void download(Library library, Release release) {
    LibraryUpdater lib = new LibraryUpdater(library, release);
    if (GraphicsEnvironment.isHeadless()) {
        FutureTask<Object> task = new FutureTask<>(lib, null);
        QUEUE.submit(task);
        try {
            task.get();
        } catch (Exception exception) {
            Log.error(exception);
        }
    } else {
        // Close any open files that come from the library
        Workspace workspace = Workspace.get();
        Path      prefix    = library.getPath();
        String    title     = library.getTitle();
        for (Dockable dockable : workspace.getDock().getDockables()) {
            if (dockable instanceof DataFileDockable) {
                DataFileDockable dfd  = (DataFileDockable) dockable;
                Path             path = dfd.getBackingFile();
                if (path != null && path.toAbsolutePath().startsWith(prefix)) {
                    if (dfd.mayAttemptClose()) {
                        if (!dfd.attemptClose()) {
                            JOptionPane.showMessageDialog(null, String.format(I18n.Text("GCS %s update was canceled."), title), I18n.Text("Canceled!"), JOptionPane.INFORMATION_MESSAGE);
                            return;
                        }
                    }
                }
            }
        }

        // Put up a progress dialog
        JDialog dialog = new JDialog(workspace, String.format(I18n.Text("Update %s"), title), true);
        dialog.setResizable(false);
        dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        dialog.setUndecorated(true);
        JComponent content = (JComponent) dialog.getContentPane();
        content.setLayout(new BorderLayout());
        content.setBorder(new CompoundBorder(new LineBorder(), new EmptyBorder(10)));
        content.add(new JLabel(String.format(I18n.Text("Downloading and installing the %s…"), title)), BorderLayout.NORTH);
        JProgressBar bar = new JProgressBar();
        bar.setIndeterminate(true);
        content.add(bar);
        dialog.pack();
        dialog.setLocationRelativeTo(workspace);
        lib.mDialog = dialog;
        QUEUE.submit(lib);
        dialog.setVisible(true);
    }
}