Example usage for javax.swing JOptionPane setOptions

List of usage examples for javax.swing JOptionPane setOptions

Introduction

In this page you can find the example usage for javax.swing JOptionPane setOptions.

Prototype

@BeanProperty(description = "The option pane's options objects.")
public void setOptions(Object[] newOptions) 

Source Link

Document

Sets the options this pane displays.

Usage

From source file:MainClass.java

public static void main(String[] a) {
    JOptionPane optionPane = new JOptionPane();
    optionPane.setMessage("Set Message");
    optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE);
    optionPane.setOptions(new Object[] { new JButton("Button") });
    JDialog dialog = optionPane.createDialog(null, "Icon/Text Button");
    dialog.setVisible(true);//from   ww w.  j  av  a  2s. c o m
}

From source file:AskingQuestionDialog.java

public static void main(String argv[]) {
    JOptionPane pane = new JOptionPane("To be or not to be ?\nThat is the question.");
    Object[] options = new String[] { "To be", "Not to be" };
    pane.setOptions(options);
    JDialog dialog = pane.createDialog(new JFrame(), "Dilaog");
    dialog.show();//w w w  . ja  v a  2  s.  c om
    Object obj = pane.getValue();
    int result = -1;
    for (int k = 0; k < options.length; k++)
        if (options[k].equals(obj))
            result = k;
    System.out.println("User's choice: " + result);
}

From source file:AddingButtonWithActionListener.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    JOptionPane optionPane = new JOptionPane();
    optionPane.setMessage("I got an icon and a text label");
    optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE);
    Icon icon = new ImageIcon("yourFile.gif");
    JButton jButton = getButton(optionPane, "OK", icon);
    optionPane.setOptions(new Object[] { jButton });
    JDialog dialog = optionPane.createDialog(frame, "Icon/Text Button");
    dialog.setVisible(true);/*from   ww w  . java 2 s . c  o m*/

}

From source file:MessagePopup.java

public static void main(String args[]) {

    JFrame frame = new JFrame("Message Popup");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton button = new JButton("Pop it");
    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            Component source = (Component) actionEvent.getSource();

            /*//from   w  w w  . j av a 2  s .  c om
             * // String msg = "this is a really long message this is a
             * really long message this is a really long message this is a
             * really long message this is a really long message this is a
             * really long message this is a really long message"; String
             * msg = " <html>this is a really long message <br> this is a
             * really long message this is a really long message this is a
             * really long message this is a really long message this is a
             * really long message this is a really long message";
             * JOptionPane.showMessageDialog(source, msg); JOptionPane
             * optionPane = OptionPaneUtils.getNarrowOptionPane(72);
             * optionPane.setMessage(msg);
             * optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE);
             * JDialog dialog = optionPane.createDialog(source, "Width 72");
             * dialog.show(); int selection =
             * OptionPaneUtils.getSelection(optionPane);
             * JOptionPane.showMessageDialog(source, msg); String
             * multiLineMsg[] = {"Hello", "World"};
             * JOptionPane.showMessageDialog(source, multiLineMsg);
             * 
             * Object complexMsg[] = {"Above Message", new
             * DiamondIcon(Color.red), new JButton ("Hello"), new JSlider(),
             * new DiamondIcon(Color.blue), "Below Message"};
             * JOptionPane.showInputDialog(source, complexMsg); JOptionPane
             * optionPane = new JOptionPane(); JSlider slider =
             * OptionPaneUtils.getSlider(optionPane);
             * optionPane.setMessage(new Object[] {"Select a value: " ,
             * slider});
             * optionPane.setMessageType(JOptionPane.QUESTION_MESSAGE);
             * optionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION);
             * JDialog dialog = optionPane.createDialog(source, "My
             * Slider"); dialog.show(); System.out.println ("Input: " +
             * optionPane.getInputValue());
             */
            JOptionPane optionPane = new JOptionPane();
            optionPane.setMessage("I got an icon and a text label");
            optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE);
            Icon icon = new DiamondIcon(Color.blue);
            JButton jButton = OptionPaneUtils.getButton(optionPane, "OK", icon);
            optionPane.setOptions(new Object[] { jButton });
            JDialog dialog = optionPane.createDialog(source, "Icon/Text Button");
            dialog.show();
        }
    };
    button.addActionListener(actionListener);
    Container contentPane = frame.getContentPane();
    contentPane.add(button, BorderLayout.SOUTH);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

private void ShowDialog() {
    JLabel label = new JLabel("Move mouse here for hand cursor");
    label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    JOptionPane pane = new JOptionPane(label);
    pane.setOptions(new Object[] { "OK" });

    JDialog dialog = pane.createDialog(this, "Test Dialog");
    dialog.setVisible(true);/*from ww w .  j  av  a 2 s. c  om*/
}

From source file:atlas.kingj.roi.FrmMain.java

private void OpenAll() {
    ResetStatusLabel();//from w ww. ja v a2  s .c o m

    formReady = false;
    jobFormReady = false;

    fc = new OpenSaveFileChooser();
    fc.setFileFilter(new OBJfilter(3));
    fc.type = 1;

    JOptionPane pane = new JOptionPane(
            "Opening a previous configuration will erase all current settings.\nAre you sure you want to proceed?");
    Object[] options = new String[] { "Yes", "No" };
    pane.setOptions(options);
    JDialog dialog = pane.createDialog(new JFrame(), "Confirm");
    dialog.setVisible(true);
    Object obj = pane.getValue();
    if (obj != null && obj.equals(options[0])) {

        int returnVal = fc.showOpenDialog(frmTitanRoiCalculator);
        if (returnVal == JFileChooser.APPROVE_OPTION) {

            SaveFile save;

            File file = fc.getSelectedFile();

            try {
                FileInputStream fin = new FileInputStream(file);
                ObjectInputStream ois = new ObjectInputStream(fin);
                save = (SaveFile) ois.readObject();
                ois.close();

                // Don't want to change the save settings in any way
                boolean temp1 = environment.SaveOnClose;
                String temp2 = environment.SaveFileName;
                environment = save.getEnvironment();
                environment.SaveOnClose = temp1;
                environment.SaveFileName = temp2;

                listModel = (DefaultListModel) save.getMachineList();
                RoiData.setSize(listModel.getSize());
                listMachines.setModel(listModel);
                jobModel = (DefaultListModel) save.getJobList();
                listJobs.setModel(jobModel);
                listJobsAvail.setModel(jobModel);
                listCompare.setModel(listModel);
                listCompareRoi.setModel(listModel);
                listCompare.setSelectedIndices(save.getSelection());
                machNames = save.getMachNames();
                jobNames = save.getJobNames();
                RoiData = (ROIData) save.getRoiData().clone();
                if (metric != environment.getUnits()) {
                    ChangeUnits();
                    rdbtnmntmImperial.setSelected(true);
                }

                chckbxSimulateScheduleStart.setSelected(!environment.StartStopTimes);

                scheduleModel.clear();
                environment.Unlocked = false;
                if (environment.getSchedule() == null)
                    environment.setSchedule(new JobSchedule());
                else {
                    int size = environment.getSchedule().getSize();
                    for (int i = 0; i < size; ++i) {
                        scheduleModel.addElement(environment.getSchedule().getJob(i));
                    }
                    btnRemoveJob.setEnabled(true);
                    btnUpSchedule.setEnabled(true);
                    btnViewSchedule.setEnabled(true);
                    btnClearSchedule.setEnabled(true);
                    if (size > 0)
                        listSchedule.setSelectedIndex(0);
                }

                formReady = false;
                UpdateForm();

                if (listModel.size() > 0) {
                    listMachines.setSelectedIndex(0);
                    formReady = true;
                }
                if (jobModel.size() > 0) {
                    listJobs.setSelectedIndex(0);
                    jobFormReady = true;
                }

                UpdateJobForm();

                // Update environment
                initialising = true;
                chckbxSimulateScheduleStart.setSelected(!environment.StartStopTimes);
                txtShiftLength.setText(Double.toString(roundTwoDecimals(environment.HrsPerShift)));
                txtShiftCount.setText(
                        Double.toString(roundTwoDecimals(environment.HrsPerDay / environment.HrsPerShift)));
                txtDaysYear.setText(
                        Double.toString(roundTwoDecimals(environment.HrsPerYear / environment.HrsPerDay)));
                initialising = false;
                UpdateShifts();

                // Update ROI form
                txtsellingprice.setText(Double.toString(roundTwoDecimals(
                        (metric ? save.RoiData.sellingprice : Core.TonToTonne(save.RoiData.sellingprice)))));
                txtcontribution.setText(Double.toString(roundTwoDecimals(save.RoiData.contribution * 100)));
                lblvalueadded.setText(
                        "" + formatDecimal((metric ? save.RoiData.value : Core.TonToTonne(save.RoiData.value)))
                                + (metric ? " / tonne" : " / ton"));
                txtenergycost.setText(Double.toString(roundTwoDecimals(save.RoiData.energycost)));
                txtwastesavedflags.setText(Double.toString(roundTwoDecimals(
                        (metric ? save.RoiData.wastesavedflag : Core.MToFt(save.RoiData.wastesavedflag)))));
                txtwastesavedguide.setText(Double.toString(roundTwoDecimals(
                        (metric ? save.RoiData.wastesavedguide : Core.MToFt(save.RoiData.wastesavedguide)))));

                UpdateAnalysis();
                UpdateROI();

                ShowMessageSuccess("File loaded successfully.");

            } catch (ClassCastException e1) {
                ShowMessage("Save-all file required, not found.");
            } catch (ClassNotFoundException e1) {
                ShowMessage("File load error.");
            } catch (FileNotFoundException e1) {
                ShowMessage("File not found.");
            } catch (Exception e1) {
                ShowMessage("File load error.");
            } finally {
                if (!(listModel.getSize() == 0))
                    formReady = true;
                if (!(jobModel.getSize() == 0))
                    jobFormReady = true;
            }

        }

    }

}

From source file:org.tellervo.desktop.prefs.Prefs.java

private static boolean cantSave(Exception e) {
    JPanel message = new JPanel(new BorderLayout(0, 8)); // (hgap,vgap)
    message.add(new JLabel(I18n.getText("error.prefs_cant_save")), BorderLayout.NORTH);

    // -- dialog with optionpane (warning?)
    JOptionPane optionPane = new JOptionPane(message, JOptionPane.ERROR_MESSAGE);
    JDialog dialog = optionPane.createDialog(null /* ? */, I18n.getText("error.prefs_cant_save_title"));

    // -- buttons: cancel, try again.
    optionPane.setOptions(new String[] { I18n.getText("question.try_again"), I18n.getText("general.cancel") });

    // -- disclosure triangle with scrollable text area: click for
    // details... (stacktrace)
    JComponent stackTrace = new JScrollPane(new JTextArea(BugReport.getStackTrace(e), 10, 60));
    JDisclosureTriangle v = new JDisclosureTriangle(I18n.getText("bug.click_for_details"), stackTrace, false);
    message.add(v, BorderLayout.CENTER);

    // -- checkbox: don't warn me again
    JCheckBox dontWarnCheckbox = new JCheckBox(I18n.getText("bug.dont_warn_again"), false);
    dontWarnCheckbox.addActionListener(new AbstractAction() {
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
            dontWarn = !dontWarn;// w w  w  .j a v  a2  s . c o m
        }
    });

    // FIXME: consolidate |message| panel construction with Layout methods
    message.add(dontWarnCheckbox, BorderLayout.SOUTH);

    // show dialog
    dialog.pack();
    dialog.setResizable(false);
    dialog.setVisible(true);

    // return true if "try again" is clicked
    return optionPane.getValue().equals(I18n.getText("try_again"));
}

From source file:processing.app.Editor.java

/**
 * Check if the sketch is modified and ask user to save changes.
 * @return false if canceling the close/quit operation
 *//*from  www .  j av  a 2s . co m*/
protected boolean checkModified() {
    if (!sketch.isModified())
        return true;

    // As of Processing 1.0.10, this always happens immediately.
    // http://dev.processing.org/bugs/show_bug.cgi?id=1456

    toFront();

    String prompt = I18n.format(_("Save changes to \"{0}\"?  "), sketch.getName());

    if (!OSUtils.isMacOS()) {
        int result = JOptionPane.showConfirmDialog(this, prompt, _("Close"), JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE);

        switch (result) {
        case JOptionPane.YES_OPTION:
            return handleSave(true);
        case JOptionPane.NO_OPTION:
            return true; // ok to continue
        case JOptionPane.CANCEL_OPTION:
        case JOptionPane.CLOSED_OPTION: // Escape key pressed
            return false;
        default:
            throw new IllegalStateException();
        }

    } else {
        // This code is disabled unless Java 1.5 is being used on Mac OS X
        // because of a Java bug that prevents the initial value of the
        // dialog from being set properly (at least on my MacBook Pro).
        // The bug causes the "Don't Save" option to be the highlighted,
        // blinking, default. This sucks. But I'll tell you what doesn't
        // suck--workarounds for the Mac and Apple's snobby attitude about it!
        // I think it's nifty that they treat their developers like dirt.

        // Pane formatting adapted from the quaqua guide
        // http://www.randelshofer.ch/quaqua/guide/joptionpane.html
        JOptionPane pane = new JOptionPane(_("<html> " + "<head> <style type=\"text/css\">"
                + "b { font: 13pt \"Lucida Grande\" }" + "p { font: 11pt \"Lucida Grande\"; margin-top: 8px }"
                + "</style> </head>" + "<b>Do you want to save changes to this sketch<BR>"
                + " before closing?</b>" + "<p>If you don't save, your changes will be lost."),
                JOptionPane.QUESTION_MESSAGE);

        String[] options = new String[] { _("Save"), _("Cancel"), _("Don't Save") };
        pane.setOptions(options);

        // highlight the safest option ala apple hig
        pane.setInitialValue(options[0]);

        // on macosx, setting the destructive property places this option
        // away from the others at the lefthand side
        pane.putClientProperty("Quaqua.OptionPane.destructiveOption", new Integer(2));

        JDialog dialog = pane.createDialog(this, null);
        dialog.setVisible(true);

        Object result = pane.getValue();
        if (result == options[0]) { // save (and close/quit)
            return handleSave(true);

        } else if (result == options[2]) { // don't save (still close/quit)
            return true;

        } else { // cancel?
            return false;
        }
    }
}

From source file:tvbrowser.TVBrowser.java

/**
 * Entry point of the application//from  w  w w  .ja  v  a  2  s  . c om
 * @param args The arguments given in the command line.
 */
public static void main(String[] args) {
    // Read the command line parameters
    parseCommandline(args);

    try {
        Toolkit.getDefaultToolkit().setDynamicLayout(
                (Boolean) Toolkit.getDefaultToolkit().getDesktopProperty("awt.dynamicLayoutSupported"));
    } catch (Exception e) {
        e.printStackTrace();
    }

    mLocalizer = util.ui.Localizer.getLocalizerFor(TVBrowser.class);

    // Check whether the TV-Browser was started in the right directory
    if (!new File("imgs").exists()) {
        String msg = "Please start TV-Browser in the TV-Browser directory!";
        if (mLocalizer != null) {
            msg = mLocalizer.msg("error.2", "Please start TV-Browser in the TV-Browser directory!");
        }
        JOptionPane.showMessageDialog(null, msg);
        System.exit(1);
    }

    if (mIsTransportable) {
        System.getProperties().remove("propertiesfile");
    }

    // setup logging

    // Get the default Logger
    Logger mainLogger = Logger.getLogger("");

    // Use a even simpler Formatter for console logging
    mainLogger.getHandlers()[0].setFormatter(createFormatter());

    if (mIsTransportable) {
        File settingsDir = new File("settings");
        try {
            File test = File.createTempFile("write", "test", settingsDir);
            test.delete();
        } catch (IOException e) {
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (Exception e1) {
                //ignore
            }

            JTextArea area = new JTextArea(mLocalizer.msg("error.noWriteRightsText",
                    "You are using the transportable version of TV-Browser but you have no writing rights in the settings directory:\n\n{0}'\n\nTV-Browser will be closed.",
                    settingsDir.getAbsolutePath()));
            area.setFont(new JLabel().getFont());
            area.setFont(area.getFont().deriveFont((float) 14).deriveFont(Font.BOLD));
            area.setLineWrap(true);
            area.setWrapStyleWord(true);
            area.setPreferredSize(new Dimension(500, 100));
            area.setEditable(false);
            area.setBorder(null);
            area.setOpaque(false);

            JOptionPane.showMessageDialog(null, area,
                    mLocalizer.msg("error.noWriteRightsTitle", "No write rights in settings directory"),
                    JOptionPane.ERROR_MESSAGE);
            System.exit(1);
        }
    }

    // Load the settings
    Settings.loadSettings();
    Locale.setDefault(new Locale(Settings.propLanguage.getString(), Settings.propCountry.getString()));

    if (Settings.propFirstStartDate.getDate() == null) {
        Settings.propFirstStartDate.setDate(Date.getCurrentDate());
    }

    if (!createLockFile()) {
        updateLookAndFeel();
        showTVBrowserIsAlreadyRunningMessageBox();
    }

    String logDirectory = Settings.propLogdirectory.getString();
    if (logDirectory != null) {
        try {
            File logDir = new File(logDirectory);
            logDir.mkdirs();
            mainLogger.addHandler(
                    new FileLoggingHandler(logDir.getAbsolutePath() + "/tvbrowser.log", createFormatter()));
        } catch (IOException exc) {
            String msg = mLocalizer.msg("error.4", "Can't create log file.");
            ErrorHandler.handle(msg, exc);
        }
    } else {
        // if no logging is configured, show WARNING or worse for normal usage, show everything for unstable versions
        if (TVBrowser.isStable()) {
            mainLogger.setLevel(Level.WARNING);
        }
    }

    // log warning for OpenJDK users
    if (!isJavaImplementationSupported()) {
        mainLogger.warning(SUN_JAVA_WARNING);
    }

    //Update plugin on version change
    if (Settings.propTVBrowserVersion.getVersion() != null
            && VERSION.compareTo(Settings.propTVBrowserVersion.getVersion()) > 0) {
        updateLookAndFeel();
        updatePluginsOnVersionChange();
    }

    // Capture unhandled exceptions
    //System.setErr(new PrintStream(new MonitoringErrorStream()));

    String timezone = Settings.propTimezone.getString();
    if (timezone != null) {
        TimeZone.setDefault(TimeZone.getTimeZone(timezone));
    }
    mLog.info("Using timezone " + TimeZone.getDefault().getDisplayName());

    // refresh the localizers because we know the language now
    Localizer.emptyLocalizerCache();
    mLocalizer = Localizer.getLocalizerFor(TVBrowser.class);
    ProgramInfo.resetLocalizer();
    ReminderPlugin.resetLocalizer();
    Date.resetLocalizer();
    ProgramFieldType.resetLocalizer();

    // Set the proxy settings
    updateProxySettings();

    // Set the String to use for indicating the user agent in http requests
    System.setProperty("http.agent", MAINWINDOW_TITLE);

    Version tmpVer = Settings.propTVBrowserVersion.getVersion();
    final Version currentVersion = tmpVer != null
            ? new Version(tmpVer.getMajor(), tmpVer.getMinor(),
                    Settings.propTVBrowserVersionIsStable.getBoolean())
            : tmpVer;

    /*TODO Create an update service for installed TV data services that doesn't
     *     work with TV-Browser 3.0 and updates for them are known.
     */
    if (!isTransportable() && Launch.isOsWindowsNtBranch() && currentVersion != null
            && currentVersion.compareTo(new Version(3, 0, true)) < 0) {
        String tvDataDir = Settings.propTVDataDirectory.getString().replace("/", File.separator);

        if (!tvDataDir.startsWith(System.getenv("appdata"))) {
            StringBuilder oldDefaultTvDataDir = new StringBuilder(System.getProperty("user.home"))
                    .append(File.separator).append("TV-Browser").append(File.separator).append("tvdata");

            if (oldDefaultTvDataDir.toString().equals(tvDataDir)) {
                Settings.propTVDataDirectory.setString(Settings.propTVDataDirectory.getDefault());
            }
        }
    }

    Settings.propTVBrowserVersion.setVersion(VERSION);
    Settings.propTVBrowserVersionIsStable.setBoolean(VERSION.isStable());

    final Splash splash;

    if (mShowSplashScreen && Settings.propSplashShow.getBoolean()) {
        splash = new SplashScreen(Settings.propSplashImage.getString(), Settings.propSplashTextPosX.getInt(),
                Settings.propSplashTextPosY.getInt(), Settings.propSplashForegroundColor.getColor());
    } else {
        splash = new DummySplash();
    }
    splash.showSplash();

    /* Initialize the MarkedProgramsList */
    MarkedProgramsList.getInstance();

    /*Maybe there are tvdataservices to install (.jar.inst files)*/
    PluginLoader.getInstance().installPendingPlugins();

    PluginLoader.getInstance().loadAllPlugins();

    mLog.info("Loading TV listings service...");
    splash.setMessage(mLocalizer.msg("splash.dataService", "Loading TV listings service..."));
    TvDataServiceProxyManager.getInstance().init();
    ChannelList.createForTvBrowserStart();

    ChannelList.initSubscribedChannels();

    if (!lookAndFeelInitialized) {
        mLog.info("Loading Look&Feel...");
        splash.setMessage(mLocalizer.msg("splash.laf", "Loading look and feel..."));

        updateLookAndFeel();
    }

    mLog.info("Loading plugins...");
    splash.setMessage(mLocalizer.msg("splash.plugins", "Loading plugins..."));
    try {
        PluginProxyManager.getInstance().init();
    } catch (TvBrowserException exc) {
        ErrorHandler.handle(exc);
    }

    splash.setMessage(mLocalizer.msg("splash.tvData", "Checking TV database..."));

    mLog.info("Checking TV listings inventory...");
    TvDataBase.getInstance().checkTvDataInventory();

    mLog.info("Starting up...");
    splash.setMessage(mLocalizer.msg("splash.ui", "Starting up..."));

    Toolkit.getDefaultToolkit().getSystemEventQueue().push(new TextComponentPopupEventQueue());

    // Init the UI
    final boolean fStartMinimized = Settings.propMinimizeAfterStartup.getBoolean() || mMinimized;
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            initUi(splash, fStartMinimized);

            new Thread("Start finished callbacks") {
                public void run() {
                    setPriority(Thread.MIN_PRIORITY);

                    mLog.info("Deleting expired TV listings...");
                    TvDataBase.getInstance().deleteExpiredFiles(1, false);

                    // first reset "starting" flag of mainframe
                    mainFrame.handleTvBrowserStartFinished();

                    // initialize program info for fast reaction to program table click
                    ProgramInfo.getInstance().handleTvBrowserStartFinished();

                    // load reminders and favorites
                    ReminderPlugin.getInstance().handleTvBrowserStartFinished();
                    FavoritesPlugin.getInstance().handleTvBrowserStartFinished();

                    // now handle all plugins and services
                    GlobalPluginProgramFormatingManager.getInstance();
                    PluginProxyManager.getInstance().fireTvBrowserStartFinished();
                    TvDataServiceProxyManager.getInstance().fireTvBrowserStartFinished();

                    // finally submit plugin caused updates to database
                    TvDataBase.getInstance().handleTvBrowserStartFinished();

                    startPeriodicSaveSettings();

                }
            }.start();
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    ChannelList.completeChannelLoading();
                    initializeAutomaticDownload();
                    if (Launch.isOsWindowsNtBranch()) {
                        try {
                            RegistryKey desktopSettings = new RegistryKey(RootKey.HKEY_CURRENT_USER,
                                    "Control Panel\\Desktop");
                            RegistryValue autoEnd = desktopSettings.getValue("AutoEndTasks");

                            if (autoEnd.getData().equals("1")) {
                                RegistryValue killWait = desktopSettings.getValue("WaitToKillAppTimeout");

                                int i = Integer.parseInt(killWait.getData().toString());

                                if (i < 5000) {
                                    JOptionPane pane = new JOptionPane();

                                    String cancel = mLocalizer.msg("registryCancel", "Close TV-Browser");
                                    String dontDoIt = mLocalizer.msg("registryJumpOver", "Not this time");

                                    pane.setOptions(new String[] { Localizer.getLocalization(Localizer.I18N_OK),
                                            dontDoIt, cancel });
                                    pane.setOptionType(JOptionPane.YES_NO_CANCEL_OPTION);
                                    pane.setMessageType(JOptionPane.WARNING_MESSAGE);
                                    pane.setMessage(mLocalizer.msg("registryWarning",
                                            "The fast shutdown of Windows is activated.\nThe timeout to wait for before Windows is closing an application is too short,\nto give TV-Browser enough time to save all settings.\n\nThe setting hasn't the default value. It was changed by a tool or by you.\nTV-Browser will now try to change the timeout.\n\nIf you don't want to change this timeout select 'Not this time' or 'Close TV-Browser'."));

                                    pane.setInitialValue(mLocalizer.msg("registryCancel", "Close TV-Browser"));

                                    JDialog d = pane.createDialog(UiUtilities.getLastModalChildOf(mainFrame),
                                            UIManager.getString("OptionPane.messageDialogTitle"));
                                    d.setModal(true);
                                    UiUtilities.centerAndShow(d);

                                    if (pane.getValue() == null || pane.getValue().equals(cancel)) {
                                        mainFrame.quit();
                                    } else if (!pane.getValue().equals(dontDoIt)) {
                                        try {
                                            killWait.setData("5000");
                                            desktopSettings.setValue(killWait);
                                            JOptionPane.showMessageDialog(
                                                    UiUtilities.getLastModalChildOf(mainFrame),
                                                    mLocalizer.msg("registryChanged",
                                                            "The timeout was changed successfully.\nPlease reboot Windows!"));
                                        } catch (Exception registySetting) {
                                            JOptionPane.showMessageDialog(
                                                    UiUtilities.getLastModalChildOf(mainFrame),
                                                    mLocalizer.msg("registryNotChanged",
                                                            "<html>The Registry value couldn't be changed. Maybe you haven't the right to do it.<br>If it is so contact you Administrator and let him do it for you.<br><br><b><Attention:/b> The following description is for experts. If you change or delete the wrong value in the Registry you could destroy your Windows installation.<br><br>To get no warning on TV-Browser start the Registry value <b>WaitToKillAppTimeout</b> in the Registry path<br><b>HKEY_CURRENT_USER\\Control Panel\\Desktop</b> have to be at least <b>5000</b> or the value for <b>AutoEndTasks</b> in the same path have to be <b>0</b>.</html>"),
                                                    Localizer.getLocalization(Localizer.I18N_ERROR),
                                                    JOptionPane.ERROR_MESSAGE);
                                        }
                                    }
                                }
                            }
                        } catch (Throwable registry) {
                        }
                    }

                    if (currentVersion != null && currentVersion.compareTo(new Version(2, 71, false)) < 0) {
                        if (Settings.propProgramPanelMarkedMinPriorityColor.getColor()
                                .equals(Settings.propProgramPanelMarkedMinPriorityColor.getDefaultColor())) {
                            Settings.propProgramPanelMarkedMinPriorityColor.setColor(new Color(255, 0, 0, 30));
                        }
                        if (Settings.propProgramPanelMarkedMediumPriorityColor.getColor()
                                .equals(Settings.propProgramPanelMarkedMediumPriorityColor.getDefaultColor())) {
                            Settings.propProgramPanelMarkedMediumPriorityColor
                                    .setColor(new Color(140, 255, 0, 60));
                        }
                        if (Settings.propProgramPanelMarkedHigherMediumPriorityColor.getColor().equals(
                                Settings.propProgramPanelMarkedHigherMediumPriorityColor.getDefaultColor())) {
                            Settings.propProgramPanelMarkedHigherMediumPriorityColor
                                    .setColor(new Color(255, 255, 0, 60));
                        }
                        if (Settings.propProgramPanelMarkedMaxPriorityColor.getColor()
                                .equals(Settings.propProgramPanelMarkedMaxPriorityColor.getDefaultColor())) {
                            Settings.propProgramPanelMarkedMaxPriorityColor
                                    .setColor(new Color(255, 180, 0, 110));
                        }
                    }

                    // check if user should select picture settings
                    if (currentVersion != null && currentVersion.compareTo(new Version(2, 22)) < 0) {
                        TvBrowserPictureSettingsUpdateDialog.createAndShow(mainFrame);
                    } else if (currentVersion != null
                            && currentVersion.compareTo(new Version(2, 51, true)) < 0) {
                        Settings.propAcceptedLicenseArrForServiceIds.setStringArray(new String[0]);
                    }

                    if (currentVersion != null && currentVersion.compareTo(new Version(2, 60, true)) < 0) {
                        int startOfDay = Settings.propProgramTableStartOfDay.getInt();
                        int endOfDay = Settings.propProgramTableEndOfDay.getInt();

                        if (endOfDay - startOfDay < -1) {
                            Settings.propProgramTableEndOfDay.setInt(startOfDay);

                            JOptionPane.showMessageDialog(UiUtilities.getLastModalChildOf(mainFrame),
                                    mLocalizer.msg("timeInfoText",
                                            "The time range of the program table was corrected because the defined day was shorter than 24 hours.\n\nIf the program table should show less than 24h use a time filter for that. That time filter can be selected\nto be the default filter by selecting it in the filter settings and pressing on the button 'Default'."),
                                    mLocalizer.msg("timeInfoTitle", "Times corrected"),
                                    JOptionPane.INFORMATION_MESSAGE);
                            Settings.handleChangedSettings();
                        }
                    }
                    MainFrame.getInstance().getProgramTableScrollPane().requestFocusInWindow();
                }
            });
        }
    });

    // register the shutdown hook
    Runtime.getRuntime().addShutdownHook(new Thread("Shutdown hook") {
        public void run() {
            deleteLockFile();
            MainFrame.getInstance().quit(false);
        }
    });
}