List of usage examples for javax.swing JDialog isDefaultLookAndFeelDecorated
public static boolean isDefaultLookAndFeelDecorated()
From source file:Main.java
/** * Initialises the {@link JDialog} for the {@link JComponent}. * //from www . j a va 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:com.googlecode.vfsjfilechooser2.VFSJFileChooser.java
/** * Creates and returns a new <code>JDialog</code> wrapping * <code>this</code> centered on the <code>parent</code> * in the <code>parent</code>'s frame. * This method can be overriden to further manipulate the dialog, * to disable resizing, set the location, etc. Example: * <pre>/*from www.java2s .com*/ * class MyFileChooser extends VFSJFileChooser { * protected JDialog createDialog(Component parent) throws HeadlessException { * JDialog dialog = super.createDialog(parent); * dialog.setLocation(300, 200); * dialog.setResizable(false); * return dialog; * } * } * </pre> * * @param parent the parent component of the dialog; * can be <code>null</code> * @return a new <code>JDialog</code> containing this instance * @exception HeadlessException if GraphicsEnvironment.isHeadless() * returns true. * @see java.awt.GraphicsEnvironment#isHeadless * @since 1.4 */ protected JDialog createDialog(Component parent) throws HeadlessException { String title = getUI().getDialogTitle(this); putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, title); Window window = null; try { window = SwingUtilities.getWindowAncestor(parent); } catch (Exception ex) { } if (window == null) { if (parent instanceof Window) { window = (Window) parent; } else { window = SHARED_FRAME; } dialog = new JDialog((Frame) window, title, true); } else if (window instanceof Frame) { dialog = new JDialog((Frame) window, title, true); } else { dialog = new JDialog((Dialog) window, title, true); } dialog.setComponentOrientation(this.getComponentOrientation()); Container contentPane = dialog.getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.add(this, BorderLayout.CENTER); if (JDialog.isDefaultLookAndFeelDecorated()) { boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations(); if (supportsWindowDecorations) { dialog.getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG); } } dialog.pack(); dialog.setLocationRelativeTo(parent); return dialog; }
From source file:org.executequery.components.FileChooserDialog.java
protected JDialog createDialog(Component parent) throws HeadlessException { Frame frame = parent instanceof Frame ? (Frame) parent : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent); String title = getUI().getDialogTitle(this); JDialog dialog = new JDialog(frame, title, true); Container contentPane = dialog.getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.add(this, BorderLayout.CENTER); setPreferredSize(new Dimension(700, getPreferredSize().height)); // add any custom panel if (customPanel != null) { contentPane.add(customPanel, BorderLayout.SOUTH); }//from w w w . j a v a 2s. c o m if (JDialog.isDefaultLookAndFeelDecorated()) { boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations(); if (supportsWindowDecorations) { dialog.getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG); } } setFileView(new DefaultFileView()); dialog.pack(); dialog.setLocation(GUIUtilities.getLocationForDialog(dialog.getSize())); return dialog; }
From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.ImportDialog.java
/** Builds and lays out the UI. */ private void buildGUI() { setLayout(new BorderLayout(0, 0)); JPanel p = new JPanel(); p.setBorder(null);/* w w w .j a v a 2 s. c om*/ p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.add(buildQuotaPane()); p.add(table); tabbedPane.add("Files to import", p); tabbedPane.add("Options", buildOptionsPane()); double[][] tablePanelDesign = { { TableLayout.PREFERRED, 10, 5, TableLayout.FILL }, { TableLayout.PREFERRED, TableLayout.FILL } }; JPanel tablePanel = new JPanel(new TableLayout(tablePanelDesign)); tablePanel.add(table.buildControls(), "0, 1, LEFT, CENTER"); tablePanel.add(tabbedPane, "2, 1, 3, 1"); int plugin = ImporterAgent.runAsPlugin(); JSplitPane pane; if (plugin == LookupNames.IMAGE_J_IMPORT || plugin == LookupNames.IMAGE_J) { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); JLabel label = UIUtilities.setTextFont("Select where to import the image(s)."); panel.add(UIUtilities.buildComponentPanel(label)); panel.add(locationDialog.getContentPane()); pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel, tablePanel); } else { pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, chooser, tablePanel); } JPanel mainPanel = new JPanel(); double[][] mainPanelDesign = { { TableLayout.FILL }, { TableLayout.PREFERRED, TableLayout.FILL } }; mainPanel.setLayout(new TableLayout(mainPanelDesign)); mainPanel.setBackground(UIUtilities.BACKGROUND); mainPanel.add(pane, "0, 1"); this.add(mainPanel, BorderLayout.CENTER); JPanel controls = new JPanel(); controls.setLayout(new BoxLayout(controls, BoxLayout.Y_AXIS)); // Lays out the buttons. JPanel bar = new JPanel(); bar.setLayout(new BoxLayout(bar, BoxLayout.X_AXIS)); bar.add(buildToolBarLeft()); bar.add(buildToolBarRight()); controls.add(new JSeparator()); controls.add(bar); add(controls, BorderLayout.SOUTH); if (JDialog.isDefaultLookAndFeelDecorated()) { boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations(); if (supportsWindowDecorations) getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG); } }