Example usage for javax.swing JDialog setDefaultLookAndFeelDecorated

List of usage examples for javax.swing JDialog setDefaultLookAndFeelDecorated

Introduction

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

Prototype

public static void setDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated) 

Source Link

Document

Provides a hint as to whether or not newly created JDialog s should have their Window decorations (such as borders, widgets to close the window, title...) provided by the current look and feel.

Usage

From source file:edu.ku.brc.ui.UIHelper.java

/**
 * Tries to do the login, if doAutoLogin is set to true it will try without displaying a dialog
 * and if the login fails then it will display the dialog
 * @param userName single signon username (for application)
 * @param password single signon password (for application)
 * @param usrPwdProvider the provider/* w ww  .j a  v  a  2 s .  co m*/
 * @param engageUPPrefs indicates whether the username and password should be loaded and remembered by local prefs
 * @param doAutoLogin whether to try to automatically log the user in
 * @param doAutoClose whether it should automatically close the window when it is logged in successfully
 * @param useDialog use a Dialog or a Frame
 * @param listener a listener for when it is logged in or fails
 * @param iconName name of icon to use
 * @param title name
 * @param appName name
 * @param appIconName application icon name
 * @param helpContext help context for Help button on dialog
 */
public static DatabaseLoginPanel doLogin(final String userName, final String password,
        final boolean engageUPPrefs, final MasterPasswordProviderIFace usrPwdProvider,
        final boolean doAutoClose, final boolean useDialog, final DatabaseLoginListener listener,
        final String iconName, final String title, final String appName, final String appIconName,
        final String helpContext, final boolean appCanUpdateSchema) //frame's icon name
{

    ImageIcon icon = IconManager.getIcon("AppIcon", IconManager.IconSize.Std32);
    if (StringUtils.isNotEmpty(appIconName)) {
        ImageIcon imgIcon = IconManager.getIcon(appIconName);
        if (imgIcon != null) {
            icon = imgIcon;
        }
    }

    if (useDialog) {
        JDialog.setDefaultLookAndFeelDecorated(false);
        DatabaseLoginDlg dlg = new DatabaseLoginDlg((Frame) UIRegistry.getTopWindow(), userName, password,
                engageUPPrefs, listener, iconName, helpContext);
        JDialog.setDefaultLookAndFeelDecorated(true);
        dlg.setDoAutoClose(doAutoClose);
        dlg.setModal(true);
        if (StringUtils.isNotEmpty(title)) {
            dlg.setTitle(title);
        }
        dlg.setIconImage(icon.getImage());
        UIHelper.centerAndShow(dlg);
        return dlg.getDatabaseLoginPanel();

    }
    // else
    class DBListener implements DatabaseLoginListener {
        protected JFrame frame;
        protected DatabaseLoginListener frameDBListener;
        protected boolean doAutoCloseOfListener;

        public DBListener(JFrame frame, DatabaseLoginListener frameDBListener, boolean doAutoCloseOfListener) {
            this.frame = frame;
            this.frameDBListener = frameDBListener;
            this.doAutoCloseOfListener = doAutoCloseOfListener;
        }

        public void loggedIn(final Window window, final String databaseName, final String userNameArg) {
            log.debug("UIHelper.doLogin[DBListener]");
            if (doAutoCloseOfListener) {
                frame.setVisible(false);
            }
            frameDBListener.loggedIn(window, databaseName, userNameArg);
        }

        public void cancelled() {
            frame.setVisible(false);
            frameDBListener.cancelled();
        }
    }
    JFrame.setDefaultLookAndFeelDecorated(false);

    JFrame frame = new JFrame(title);
    DatabaseLoginPanel panel;
    if (StringUtils.isNotEmpty(title)) {
        panel = new DatabaseLoginPanel(userName, password, engageUPPrefs, usrPwdProvider,
                new DBListener(frame, listener, doAutoClose), false, true, title, appName, iconName,
                helpContext);
    } else {
        panel = new DatabaseLoginPanel(userName, password, engageUPPrefs, usrPwdProvider,
                new DBListener(frame, listener, doAutoClose), false, true, null, null, iconName, helpContext);
    }

    panel.setAppCanUpdateSchema(appCanUpdateSchema);
    panel.setAutoClose(doAutoClose);
    panel.setWindow(frame);
    frame.setContentPane(panel);
    frame.setIconImage(icon.getImage());
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    frame.pack();

    UIHelper.centerAndShow(frame);

    return panel;
}

From source file:edu.ku.brc.ui.UIHelper.java

/**
 * Tries to do the login, if doAutoLogin is set to true it will try without displaying a dialog
 * and if the login fails then it will display the dialog
 * @param doAutoLogin whether to try to utomatically log the user in
 * @param doAutoClose hwther it should automatically close the window when it is logged in successfully
 * @param useDialog use a Dialog or a Frame
 * @param compileListener a listener for when it is logged in or fails
 *///from   w w  w  .j  av a 2 s  .  co  m
public static CustomDBConverterDlg doSpecifyConvert() {
    log.debug("doSpecifyConvert");
    CustomDBConverter converter = new CustomDBConverter();
    converter.setUpSystemProperties();
    converter.setUpPreferrences();
    final CustomDBConverterListener listener = converter;
    JDialog.setDefaultLookAndFeelDecorated(false);
    CustomDBConverterDlg dlg = new CustomDBConverterDlg((Frame) UIRegistry.getTopWindow(), listener);
    JDialog.setDefaultLookAndFeelDecorated(true);
    UIHelper.centerAndShow(dlg);
    return dlg;
}

From source file:com.lfv.lanzius.application.Controller.java

public synchronized void settingsDialogOpen() {
    if (state != CLIENT_STATE_STARTED)
        return;//from w  w  w  .  ja  v a2s  .  co m
    // This button is also used to stop the auto tester
    if (autoTesterEnabled) {
        autoTester.stopTester();
        JOptionPane.showMessageDialog(view,
                "The auto tester has been stopped! The settings dialog\n"
                        + "is unaccessible when the auto tester is enabled!",
                "Auto tester", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    if (settingsDialog == null) {
        boolean full = properties.getUserInterfaceStyle().equalsIgnoreCase("full");
        if (!full)
            JDialog.setDefaultLookAndFeelDecorated(true);

        settingsDialog = new JDialog(view, "Settings", false);
        settingsDialog.setContentPane(new SettingsPane(this));

        if (full) {
            settingsDialog.setResizable(false);
            settingsDialog.setUndecorated(true);
            Rectangle rect = view.getBounds();
            rect.x += rect.width * 0.1;
            rect.y += rect.height * 0.1;
            rect.width *= 0.8;
            rect.height *= 0.8;
            settingsDialog.setBounds(rect);

            // Hide mouse cursor if stated in the properties file
            if (properties.isMouseCursorHidden())
                settingsDialog.setCursor(InvisibleCursor.getCursor());
        } else {
            GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
            Rectangle rect = graphicsEnvironment.getMaximumWindowBounds();
            rect.x += rect.width * 0.25;
            rect.y += rect.height * 0.25;
            rect.width *= 0.5;
            rect.height *= 0.5;
            settingsDialog.setBounds(rect);
            settingsDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
            settingsDialog.addWindowListener(new WindowAdapter() {
                @Override
                public void windowClosing(WindowEvent e) {
                    settingsDialogClose();
                }
            });
        }

        settingsDialog.setVisible(true);
    }
}

From source file:com.lfv.lanzius.application.Controller.java

/**
 * Open the ISA dialog (if the radio has been silent for at least 2 seconds)
 * @return true if the dialog was opened
 *///  ww  w.  java 2  s  .co m
public boolean isaDialogOpen(int isaNumChoices, boolean isaExtendedMode, String isakeytext[]) {
    final int radioSilentLimit = 500; // Do not show ISA dialog until at least half a second of silence
    if (view == null)
        return true; // This might happen if ISA request when terminal is starting up, don't open ISA dialog
    if (isaDialog == null) {
        // Is radio or phone active?
        boolean codecActive = (radioEncoding || radioDecoding || phoneActive);
        // Wait for 2 seconds of radio silence
        if (codecActive || (System.currentTimeMillis() - radioIdleTime) < radioSilentLimit) {
            // Ignore ISA request if too busy
            return false;
        }

        boolean full = properties.getUserInterfaceStyle().equalsIgnoreCase("full");
        if (!full)
            JDialog.setDefaultLookAndFeelDecorated(true);

        isaDialog = new JDialog(view, "Workload", false);
        isaDialog.setContentPane(
                new ISAPane(Controller.getInstance(), isaNumChoices, isaExtendedMode, isakeytext));

        if (full) {
            isaDialog.setResizable(false);
            isaDialog.setUndecorated(true);
            Rectangle rect = view.getBounds();
            if (isaExtendedMode) {
                rect.x += rect.width * 0.3;
                rect.y += rect.height * 0.3;
                rect.width *= 0.4;
                rect.height *= 0.5;
            } else {
                rect.x += rect.width * 0.2;
                rect.y += rect.height * 0.4;
                rect.width *= 0.6;
                rect.height *= 0.15;
            }
            isaDialog.setBounds(rect);

            // Hide mouse cursor if stated in the properties file
            if (properties.isMouseCursorHidden())
                isaDialog.setCursor(InvisibleCursor.getCursor());
        } else {
            GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
            Rectangle rect = graphicsEnvironment.getMaximumWindowBounds();
            if (isaExtendedMode) {
                rect.x = (int) (rect.width - (rect.width * 0.2));
                rect.y = (int) (rect.height - (rect.height * 0.25));
                rect.width *= 0.2;
                rect.height *= 0.25;
            } else {
                rect.x = (int) (rect.width - (rect.width * 0.3));
                rect.y = (int) (rect.height - (rect.height * 0.1));
                rect.width *= 0.3;
                rect.height *= 0.1;
            }
            isaDialog.setBounds(rect);
            isaDialog.addWindowListener(new WindowAdapter() {
                @Override
                public void windowClosing(WindowEvent e) {
                    isaValueChosen(0);
                }
            });
        }
        isaDialog.setVisible(true);
        isaReqStartTime = System.currentTimeMillis();
        clipNotify.playOnce();
    }
    return true;
}

From source file:com.lfv.lanzius.server.LanziusServer.java

public static void start() {

    server = new LanziusServer();

    // Make sure we have nice window decorations.
    // Only if workspace is not fullscreen
    if (!Config.SERVER_SIZE_FULLSCREEN)
        JFrame.setDefaultLookAndFeelDecorated(true);
    JDialog.setDefaultLookAndFeelDecorated(true);

    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            server.init();//w  ww .j a v a 2  s. c om
        }
    });
}

From source file:net.team2xh.crt.gui.util.GUIToolkit.java

/**
 * Activeate Substance Look&Feel.//  w  w  w .  j  av  a  2  s.c o  m
 *
 * Must be called before opening any window.
 * 
 * @param laf Desired Substance Look&Feel class
 */
public static void setSubstanceLAF(String laf) {
    try {
        UIManager.setLookAndFeel(laf);
        UIManager.put(SubstanceLookAndFeel.WINDOW_ROUNDED_CORNERS, Boolean.FALSE);
        JFrame.setDefaultLookAndFeelDecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(true);

        // Substance forgot to put a border for JTextArea,
        // So we give it the same border that TextField has
        Object border = UIManager.get("TextField.border");
        UIManager.put("TextArea.border", border);
        // Plain title font
        //            SubstanceLookAndFeel.setFontPolicy(new FontPolicy() {
        //                public FontSet getFontSet(String arg0, UIDefaults arg1) {
        //                    FontSet fontSet = new FontSet() {
        //                        public FontUIResource getWindowTitleFont() {
        //                            return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14)); //this is where the title font changes
        //                        }
        //
        //                        public FontUIResource getTitleFont() {
        //                            return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14));
        //                        }
        //
        //                        public FontUIResource getSmallFont() {
        //                            return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14));
        //                        }
        //
        //                        public FontUIResource getMessageFont() {
        //                            return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14));
        //                        }
        //
        //                        public FontUIResource getMenuFont() {
        //                            return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14));
        //                        }
        //
        //                        public FontUIResource getControlFont() {
        //                            return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14));
        //                        }
        //                    };
        //                    return fontSet;
        //                }
        //            });        
    } catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException
            | IllegalAccessException ex) {
        Logger.getLogger(GUIToolkit.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:org.executequery.util.LookAndFeelLoader.java

public void decorateDialogsAndFrames(boolean decorateDialogs, boolean decorateFrames) {

    JDialog.setDefaultLookAndFeelDecorated(decorateDialogs);
    JFrame.setDefaultLookAndFeelDecorated(decorateFrames);
}

From source file:org.gridchem.client.GridChem.java

public static void main(String[] args) {
    Trace.entry();/*from ww w .j  a  va2s .  c  o m*/

    try {
        setCommandLineOptions();
        parseCommandLine(args);
    } catch (Exception e) {
        System.out.println("Invalid command line option given: " + e.getMessage());
    }

    //JFrame.setDefaultLookAndFeelDecorated(true);
    JFrame frame = new JFrame();

    // Edited by Shashank & Sandeep @ CCS,UKY April 10 2005
    JFrame.setDefaultLookAndFeelDecorated(true);
    JDialog.setDefaultLookAndFeelDecorated(true);
    /*MetalTheme theme = new G03Input.ColorTheme();  
    MetalLookAndFeel.setCurrentTheme(theme);
    try {
        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
        SwingUtilities.updateComponentTreeUI(frame);
    } catch(Exception e) {
        System.out.println(e);
    }*/

    // Use the native look and feel since Java's is pretty lame.
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        // Ignore exceptions, which only result in the wrong look and feel.
        System.out.println("GridChem.main: an exception related to the" + " look and feel was ignored.");
    }

    init();

    frame.setTitle("GridChem " + Env.getVersion());
    frame.getContentPane().add(oc);
    frame.addWindowListener(new WindowListener() {

        public void windowActivated(WindowEvent arg0) {
        }

        public void windowClosed(WindowEvent arg0) {
        }

        public void windowClosing(WindowEvent arg0) {
            if (Settings.authenticated) {
                GMS3.logout();
            }
        }

        public void windowDeactivated(WindowEvent arg0) {
        }

        public void windowDeiconified(WindowEvent arg0) {
        }

        public void windowIconified(WindowEvent arg0) {
        }

        public void windowOpened(WindowEvent arg0) {
        }

    });
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();

    // Centering the frame on the screen
    Toolkit kit = frame.getToolkit();
    Dimension screenSize = kit.getScreenSize();
    int screenWidth = screenSize.width;
    int screenHeight = screenSize.height;
    Dimension windowSize = frame.getSize();
    int windowWidth = windowSize.width;
    int windowHeight = windowSize.height;
    int upperLeftX = (screenWidth - windowWidth) / 2;
    int upperLeftY = (screenHeight - windowHeight) / 2;
    frame.setLocation(upperLeftX, upperLeftY);
    frame.setVisible(true);

    Trace.exit();
}

From source file:org.notebook.gui.widget.LookAndFeelSelector.java

/**
 * Sets the look and feel.//from  w w w. j  a  v a  2  s.co  m
 * 
 * @param theme
 *            the new look and feel
 */
public void setLookAndFeel(String theme) {
    try {
        log.info("Updating skin '" + theme + "'");
        if (skins.containsKey(theme)) {
            UIManager.setLookAndFeel(skins.get(theme));
        } else {
            log.error("Not found skin '" + theme + "'");
            return;
        }

        /** fix font bug start */
        if (SwingUtilities.isEventDispatchThread()) {
            fixFontBug();
        } else {
            SwingUtilities.invokeAndWait(new Runnable() {
                @Override
                public void run() {
                    fixFontBug();
                }
            });
        }
    } catch (Exception e) {
        log.error(e.toString(), e);
    }

    /**
     * ??????
     * tiptool
     */
    if (!isDefaultLookAndFeel(theme)) {
        // Get border color
        try {
            Color c = SubstanceLookAndFeel.getCurrentSkin().getMainActiveColorScheme().getMidColor();
            UIManager.put("ToolTip.border", BorderFactory.createLineBorder(c));
            UIManager.put("ToolTip.background", new ColorUIResource(Color.WHITE));
            UIManager.put("ToolTip.foreground", new ColorUIResource(Color.BLACK));

            SubstanceSkin skin = SubstanceLookAndFeel.getCurrentSkin();
            SubstanceColorScheme scheme = skin.getMainActiveColorScheme();

            GuiUtils.putLookAndFeelColor("borderColor", scheme.getMidColor());
            GuiUtils.putLookAndFeelColor("lightColor", scheme.getLightColor());
            GuiUtils.putLookAndFeelColor("lightBackgroundFillColor", scheme.getLightBackgroundFillColor());
            GuiUtils.putLookAndFeelColor("darkColor", scheme.getDarkColor());
            GuiUtils.putLookAndFeelColor("backgroundFillColor", scheme.getBackgroundFillColor());
            GuiUtils.putLookAndFeelColor("lineColor", scheme.getLineColor());
            GuiUtils.putLookAndFeelColor("selectionForegroundColor", scheme.getSelectionForegroundColor());
            GuiUtils.putLookAndFeelColor("selectionBackgroundColor", scheme.getSelectionBackgroundColor());
            GuiUtils.putLookAndFeelColor("foregroundColor", scheme.getForegroundColor());
            GuiUtils.putLookAndFeelColor("focusRingColor", scheme.getFocusRingColor());

        } catch (Exception e) {
            log.info("This is not a SubstanceLookAndFeel skin.");
        }

        UIManager.put(LafWidget.ANIMATION_KIND, LafConstants.AnimationKind.NONE);
        UIManager.put(SubstanceLookAndFeel.TABBED_PANE_CONTENT_BORDER_KIND,
                SubstanceConstants.TabContentPaneBorderKind.SINGLE_FULL);

        JFrame.setDefaultLookAndFeelDecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(true);
    }
}

From source file:picocash.Picocash.java

@Override
protected void initialize(String[] arg0) {
    ServiceDiscover.getAll(IPicocashPersistenceManager.class);
    Services.setSelectedPersistenceMan(ServiceDiscover.getSingleton(IPicocashPersistenceManager.class));

    Services.getSelectedPersistenceMan().setDatabaseName("test.mmoc");
    try {//  w  w w  .java2  s .c  o m
        Services.getSelectedPersistenceMan().initDB();
    } catch (Exception ex) {
        log.fatal("Exception while restarting database:", ex);
        exit();
    }

    PicocashIcons.init();

    JFrame.setDefaultLookAndFeelDecorated(true);
    JDialog.setDefaultLookAndFeelDecorated(true);

    addExitListener(new ExitListener() {

        @Override
        public boolean canExit(EventObject event) {
            if (changesAvailable) {
                int retValue = JOptionPane.showConfirmDialog(getMainFrame(), "Das sollte der Title sein",
                        "und die Message", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (retValue == JOptionPane.OK_OPTION) {
                    save();
                }
                return retValue == JOptionPane.OK_OPTION || retValue == JOptionPane.CANCEL_OPTION;
            }
            return true;
        }

        @Override
        public void willExit(EventObject event) {
            Services.getSelectedPersistenceMan().close();
        }
    });
    super.initialize(arg0);
}