Example usage for javax.swing JDialog pack

List of usage examples for javax.swing JDialog pack

Introduction

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

Prototype

@SuppressWarnings("deprecation")
public void pack() 

Source Link

Document

Causes this Window to be sized to fit the preferred size and layouts of its subcomponents.

Usage

From source file:psidev.psi.mi.validator.client.gui.DragAndDropValidator.java

/**
 * Sets up the menu bar of the main window.
 *
 * @param frame the frame onto which we attach the menu bar
 * @param table the table that allow to command the validator.
 * @param level the level of log message.
 *//* ww w  .ja  va 2 s.c om*/
public static void setupMenus(final JFrame frame, final Validator validator, final ValidatorTable table,
        final MessageLevel level) {

    // Create the fileMenu bar
    JMenuBar menuBar = new JMenuBar();

    final UserPreferences preferences = validator.getUserPreferences();

    ////////////////////////////
    // 1. Create a file menu
    JMenu fileMenu = new JMenu("File");
    menuBar.add(fileMenu);

    // Create a file Menu items
    JMenuItem openFile = new JMenuItem("Open file...");
    openFile.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            GuiUserPreferences guiPrefs = new GuiUserPreferences(preferences);

            File lastDirectory = userPreferences.getLastOpenedDirectory();

            JFileChooser fileChooser = new JFileChooser(lastDirectory);
            fileChooser.addChoosableFileFilter(new XmlFileFilter());

            // Open file dialog.
            fileChooser.showOpenDialog(frame);

            File selected = fileChooser.getSelectedFile();

            if (selected != null) {
                userPreferences.setLastOpenedDirectory(selected.getParentFile());

                // start validation of the selected file.
                ValidatorTableRow row = new ValidatorTableRow(selected, level, true);

                table.addTableRow(row);
            }
        }
    });
    fileMenu.add(openFile);

    // exit menu item
    JMenuItem exit = new JMenuItem("Exit");
    exit.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            System.exit(0);
        }
    });
    fileMenu.add(exit);

    ///////////////////////////////
    // 2. TODO setup messages menu

    //        JMenu msgMenu = new JMenu( "Messages" );
    //        menuBar.add( msgMenu );
    //
    //        // Create a clear all messages item
    //        JMenuItem clearAll = new JMenuItem( "Clear all" );
    //        openFile.addActionListener( new ActionListener() {
    //
    //            public void actionPerformed( ActionEvent e ) {
    //
    //                // remove all elements
    //                table.removeAllRows( );
    //            }
    //        } );
    //        msgMenu.add( clearAll );

    //////////////////////////////
    // Log level

    // TODO create a menu that allows to switch log level at run time.

    /////////////////////////
    // 3. setup help menu
    JMenu helpMenu = new JMenu("Help");
    menuBar.add(helpMenu);

    JMenuItem about = new JMenuItem("About...");
    about.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JOptionPane msg = new JOptionPane("Version " + VERSION + NEW_LINE + "Authors: " + AUTHORS);
            JDialog dialog = msg.createDialog(frame, "About PSI Validator");
            dialog.setResizable(true);
            dialog.pack();
            dialog.setVisible(true);
        }
    });
    helpMenu.add(about);

    // Install the fileMenu bar in the frame
    frame.setJMenuBar(menuBar);
}

From source file:ro.nextreports.designer.action.chart.PreviewChartAction.java

public void actionPerformed(ActionEvent event) {

    executorThread = new Thread(new Runnable() {

        public void run() {

            if (ChartUtil.chartUndefined(chart)) {
                return;
            }/*w w w  . ja v a2s.  c o  m*/

            ParametersBean pBean = NextReportsUtil.selectParameters(chart.getReport(), null);
            if (pBean == null) {
                return;
            }

            UIActivator activator = new UIActivator(Globals.getMainFrame(),
                    I18NSupport.getString("preview.chart.execute"));
            activator.start(new PreviewStopAction());

            ChartWebServer webServer = ChartWebServer.getInstance();
            String webRoot = webServer.getWebRoot();

            ChartRunner runner = new ChartRunner();
            runner.setFormat(chartRunnerType);
            runner.setGraphicType(chartGraphicType);
            runner.setChart(chart);
            runner.setQueryTimeout(Globals.getQueryTimeout());
            runner.setParameterValues(pBean.getParamValues());
            I18nLanguage language = I18nUtil.getDefaultLanguage(chart);
            if (language != null) {
                runner.setLanguage(language.getName());
            }
            if (ChartRunner.IMAGE_FORMAT.equals(runner.getFormat())) {
                runner.setImagePath(Globals.USER_DATA_DIR + "/reports");
            }
            Connection con = null;
            try {
                DataSource runDS = Globals.getChartLayoutPanel().getRunDataSource();
                boolean csv = runDS.getDriver().equals(CSVDialect.DRIVER_CLASS);
                con = Globals.createTempConnection(runDS);
                runner.setConnection(con, csv);
                if (ChartRunner.IMAGE_FORMAT.equals(runner.getFormat())) {
                    runner.run();
                    JDialog dialog = new JDialog(Globals.getMainFrame(), "");
                    dialog.setBackground(Color.WHITE);
                    dialog.setLayout(new BorderLayout());
                    ShowImagePanel panel = new ShowImagePanel(runner.getChartImageAbsolutePath());
                    dialog.add(panel, BorderLayout.CENTER);
                    dialog.pack();
                    dialog.setResizable(false);
                    Show.centrateComponent(Globals.getMainFrame(), dialog);
                    dialog.setVisible(true);
                } else {
                    String jsonFile = "data.json";
                    if (ChartRunner.HTML5_TYPE == runner.getGraphicType()) {
                        jsonFile = "data-html5.json";
                    }
                    OutputStream outputStream = new FileOutputStream(webRoot + File.separatorChar + jsonFile);
                    boolean result = runner.run(outputStream);
                    outputStream.close();
                    if (result) {
                        if (!webServer.isStarted()) {
                            webServer.start();
                        }
                        if (ChartRunner.HTML5_TYPE == runner.getGraphicType()) {
                            FileUtil.openUrl(
                                    "http://localhost:" + Globals.getChartWebServerPort() + "/chart-html5.html",
                                    PreviewChartAction.class);
                        } else {
                            FileUtil.openUrl("http://localhost:" + Globals.getChartWebServerPort()
                                    + "/chart.html?ofc=data.json", PreviewChartAction.class);
                        }
                    }
                }

            } catch (NoDataFoundException e) {
                Show.info(I18NSupport.getString("run.nodata"));
            } catch (InterruptedException e) {
                Show.dispose(); // close a possible previous dialog message
                Show.info(I18NSupport.getString("preview.cancel"));
            } catch (Exception e) {
                e.printStackTrace();
                Show.error(e);
            } finally {
                if (con != null) {
                    try {
                        con.close();
                    } catch (SQLException e) {
                        e.printStackTrace();
                        LOG.error(e.getMessage(), e);
                    }
                }
                stop = false;
                if (activator != null) {
                    activator.stop();
                    activator = null;
                }

                // restore old parameters if chart was runned from tree
                if (oldParameters != null) {
                    ParameterManager.getInstance().setParameters(oldParameters);
                }
            }
        }
    }, "NEXT : " + getClass().getSimpleName());
    executorThread.setPriority(EngineProperties.getRunPriority());
    executorThread.start();
}

From source file:ro.nextreports.designer.wizpublish.DownloadListWizardPanel.java

private void createSelectionDialog(final byte type) {
    WebServiceClient client = (WebServiceClient) context.getAttribute(PublishWizard.CLIENT);
    final JcrBrowserTree jcrBrowserTree = new JcrBrowserTree(type, client);
    jcrBrowserTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    JPanel selectionPanel = JcrBrowserTreeUtil.createSelectionPanel(jcrBrowserTree, type);

    JDialog dialog = new BaseDialog(selectionPanel, I18NSupport.getString("wizard.publish.file.path.select"),
            true) {/* ww w.  ja v  a 2 s  . c  o  m*/
        protected boolean ok() {
            return selection(jcrBrowserTree, type);
        }
    };
    dialog.pack();
    Show.centrateComponent((JDialog) context.getAttribute(PublishWizard.MAIN_FRAME), dialog);
    dialog.setVisible(true);
}

From source file:ro.nextreports.designer.wizpublish.PublishFileWizardPanel.java

private void createSelectionDialog(final byte type) {
    WebServiceClient client = (WebServiceClient) context.getAttribute(PublishWizard.CLIENT);
    final JcrBrowserTree jcrBrowserTree = new JcrBrowserTree(type, client);
    JPanel selectionPanel = JcrBrowserTreeUtil.createSelectionPanel(jcrBrowserTree, type);

    String message = "";
    if ((type == DBObject.REPORTS_GROUP) || (type == DBObject.CHARTS_GROUP)) {
        message = I18NSupport.getString("wizard.publish.file.path.select");
    } else if (type == DBObject.DATABASE) {
        message = I18NSupport.getString("wizard.publish.file.source");
    }// w  w w.j a v  a2 s .c o  m
    JDialog dialog = new BaseDialog(selectionPanel, message, true) {
        protected boolean ok() {
            return selection(jcrBrowserTree, type);
        }
    };
    dialog.pack();
    Show.centrateComponent((JDialog) context.getAttribute(PublishWizard.MAIN_FRAME), dialog);
    dialog.setVisible(true);
}

From source file:ro.nextreports.designer.wizpublish.SelectEntityWizardPanel.java

private void add() {
    // ignore double click listener for tree (which opens the query)
    // and create our own listener (which just selects the path)
    final DBBrowserTree dbBrowserTree = new DBBrowserTree(type, false);
    dbBrowserTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    dbBrowserTree.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            job(e, true);/*from w ww  .  ja  v a  2 s .  c  o  m*/
        }

        public void mouseReleased(MouseEvent e) {
            job(e, false);
        }

        private void job(MouseEvent e, boolean pressed) {
            TreePath[] paths = dbBrowserTree.getSelectionPaths();
            if (paths == null) {
                return;
            }
            dbBrowserTree.setSelectionPaths(paths);
        }
    });
    JScrollPane scroll = new JScrollPane(dbBrowserTree);
    scroll.setPreferredSize(scrTreeDim);

    JPanel panel = new JPanel();
    panel.add(scroll);

    JDialog dialog = new BaseDialog(panel, I18NSupport.getString("wizard.publish.entities.select"), true) {
        protected boolean ok() {
            TreePath[] paths = dbBrowserTree.getSelectionPaths();
            if (paths == null) {
                return false;
            }
            for (TreePath selPath : paths) {
                final DBBrowserNode selectedNode = (DBBrowserNode) selPath.getLastPathComponent();
                if (!selectedNode.getDBObject().isFolder()) {
                    String path = selectedNode.getDBObject().getAbsolutePath();
                    if (!listModel.contains(path)) {
                        // convert xml if needed before add to list
                        if (selectedNode.getDBObject().getType() == DBObject.REPORTS) {
                            byte result = ConverterUtil.convertIfNeeded(path);
                            if (result != ConverterUtil.TYPE_CONVERSION_EXCEPTION) {
                                listModel.addElement(path);
                            }
                        } else {
                            listModel.addElement(path);
                        }
                    }
                }
            }
            return true;
        }
    };
    dialog.setBackground(Color.WHITE);
    dialog.pack();
    Show.centrateComponent(Globals.getMainFrame(), dialog);
    dialog.setVisible(true);
}

From source file:savant.format.SavantFileFormatter.java

public static void reportFormattingError(final Throwable x, final File inFile) {
    if (x instanceof InterruptedException) {
        DialogUtils.displayMessage("Format cancelled.");
    } else if (x instanceof SavantFileFormattingException) {
        // Not a Savant error.  They've just chosen the wrong kind of file.
        DialogUtils.displayMessage("Format Unsuccessful", x.getMessage());
    } else {/*w  w w .j a  v a 2s  .  c o  m*/
        JideOptionPane optionPane = new JideOptionPane(String.format(
                "<html>Message: <i>%s</i><br><br>Click the <i>Details</i> button to see more information...<br><br>"
                        + "Please report any issues you experience to the to the development team.</html>",
                MiscUtils.getMessage(x)), JOptionPane.ERROR_MESSAGE, JideOptionPane.CLOSE_OPTION);
        optionPane.setTitle("A problem was encountered while formatting.");
        optionPane.setOptions(new String[] {});
        JButton reportButton = new JButton("Report Issue");
        ((JComponent) optionPane.getComponent(optionPane.getComponentCount() - 1)).add(reportButton);
        final JDialog dialog = optionPane.createDialog(DialogUtils.getMainWindow(), "Format Unsuccessful");
        dialog.setModal(true);
        dialog.setResizable(true);
        optionPane.setDetails(MiscUtils.getStackTrace(x));
        //optionPane.setDetailsVisible(true);
        dialog.pack();

        reportButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e2) {
                String issue = "I am having trouble formatting my file for use with Savant.\nI have provided additional diagnostic information below.\n\n";

                issue += "SOURCE OF FILE: [e.g. UCSC]\n\n";
                issue += "TYPE: [e.g. BED]\n\n";
                issue += "CONTENTS: [e.g. human genes]\n\n";
                issue += "PATH: " + inFile + "\n\n";
                issue += "ADDITIONAL COMMENTS:\n\n";

                dialog.dispose();
                new BugReportDialog(Savant.getInstance(), issue).setVisible(true);
            }

        });

        dialog.setVisible(true);
    }
}

From source file:savant.view.swing.BookmarkSheet.java

private void loadBookmarks(JTable table) {
    final BookmarksTableModel btm = (BookmarksTableModel) table.getModel();
    List<Bookmark> bookmarks = btm.getData();

    if (bookmarks.size() > 0) {
        String message = "Clear existing bookmarks?";
        String title = "Clear Bookmarks";
        // display the JOptionPane showConfirmDialog
        int reply = JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_OPTION);
        if (reply == JOptionPane.YES_OPTION) {
            btm.clearData();//from w  w w.  j av a2 s. com
            BookmarkController.getInstance().clearBookmarks();
        }
    }

    final File selectedFile = DialogUtils.chooseFileForOpen("Load Bookmarks", null, null);

    // set the genome
    if (selectedFile != null) {

        int result = JOptionPane.showOptionDialog(null, "Would you like to add padding to each bookmark range?",
                "Add a margin?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
        final boolean addMargin = (result == JOptionPane.YES_OPTION);

        Window w = SwingUtilities.getWindowAncestor(BookmarkSheet.this);
        JOptionPane optionPane = new JOptionPane(
                "<html>Loading bookmarks from file.<br>This may take a moment.</html>",
                JOptionPane.INFORMATION_MESSAGE, JOptionPane.CANCEL_OPTION);
        final JDialog dialog = new JDialog(w, "Loading Bookmarks", Dialog.ModalityType.MODELESS);
        dialog.setContentPane(optionPane);
        dialog.pack();
        dialog.setLocationRelativeTo(w);
        dialog.setVisible(true);
        new Thread("BookmarkSheet.loadBookmarks") {
            @Override
            public void run() {
                try {
                    BookmarkController.getInstance().addBookmarksFromFile(selectedFile, addMargin);
                    btm.fireTableDataChanged();
                } catch (Exception ex) {
                    DialogUtils.displayError("Error", "Unable to load bookmarks: " + ex.getMessage());
                } finally {
                    dialog.setVisible(false);
                    dialog.dispose();
                }
            }
        }.start();
    }
}

From source file:tvbrowser.ui.mainframe.MainFrame.java

private void quit(boolean log, boolean export) {
    mTimer.stop(); // disable the update timer to avoid new update events
    if (log && downloadingThread != null && downloadingThread.isAlive()) {
        final JDialog info = new JDialog(UiUtilities.getLastModalChildOf(this));
        info.setModal(true);/*  w w  w .j a v a  2 s  .  c o m*/
        info.setUndecorated(true);
        info.toFront();

        JPanel main = new JPanel(new FormLayout("5dlu,pref,5dlu", "5dlu,pref,5dlu"));
        main.setBorder(BorderFactory.createLineBorder(Color.black));
        main.add(
                new JLabel(mLocalizer.msg("downloadinfo",
                        "A data update is running. TV-Browser will be closed when the update is done.")),
                new CellConstraints().xy(2, 2));

        info.setContentPane(main);
        info.pack();
        info.setLocationRelativeTo(this);

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                if (downloadingThread != null && downloadingThread.isAlive()) {
                    try {
                        downloadingThread.join();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

                info.setVisible(false);
                info.dispose();
            }
        });

        info.setVisible(true);
    }
    if (log && this.isUndecorated()) {
        switchFullscreenMode();
    }
    if (mShuttingDown) {
        return;
    }
    mShuttingDown = true;

    if (log) {
        FavoritesPlugin.getInstance().handleTvBrowserIsShuttingDown();
    }

    if (log) {
        mLog.info("Finishing plugins");
    }
    PluginProxyManager.getInstance().shutdownAllPlugins(log);

    if (log) {
        mLog.info("Storing dataservice settings");
    }
    TvDataServiceProxyManager.getInstance().shutDown();

    FavoritesPlugin.getInstance().store();
    ReminderPlugin.getInstance().store();

    TVBrowser.shutdown(log);

    if (log) {
        mLog.info("Closing TV data base");
    }

    try {
        TvDataBase.getInstance().close();
    } catch (Exception exc) {
        if (log) {
            mLog.log(Level.WARNING, "Closing database failed", exc);
        }
    }

    if (export) {
        Settings.propTVDataDirectory.resetToDefault();
        Settings.copyToSystem();
    }

    if (log) {
        mLog.info("Quitting");
        System.exit(0);
    }
}

From source file:ucar.unidata.ui.HttpFormEntry.java

/**
 * Show the UI in a modeful dialog. Note: The calling method is responsible
 * for disposing of the dialog. Also: This method <b>should not</b> be called
 * from a swing process. It does a busy wait on the dialog and does not rely on
 * the modality of the dialog to do its wait.
 *
 * @param entries List of entries// www . ja  v  a2  s.c  o  m
 * @param extraTop If non-null then this is added to the top of the gui.
 *                 It allows you to provide a label, etc.
 * @param extraBottom Like extraTop but on the bottom of the window
 * @param dialog  the dialog
 * @param shouldDoBusyWait true to wait
 *
 * @return Did user press ok
 */
public static boolean showUI(final List entries, JComponent extraTop, JComponent extraBottom,
        final JDialog dialog, final boolean shouldDoBusyWait) {

    dialog.getContentPane().removeAll();
    JComponent contents = makeUI(entries);
    if (extraTop != null) {
        contents = GuiUtils.topCenter(extraTop, contents);
    }

    if (extraBottom != null) {
        contents = GuiUtils.centerBottom(contents, extraBottom);
    }
    final boolean[] done = { false };
    final boolean[] ok = { false };

    ActionListener listener = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            String cmd = ae.getActionCommand();
            if (cmd.equals(GuiUtils.CMD_CANCEL)) {
                done[0] = true;
            }
            if (cmd.equals(GuiUtils.CMD_SUBMIT)) {
                if (checkEntries(entries)) {
                    done[0] = true;
                    ok[0] = true;
                }
            }
            if (done[0] && !shouldDoBusyWait) {
                dialog.dispose();
            }
        }
    };

    JComponent buttons = GuiUtils.makeButtons(listener,
            new String[] { GuiUtils.CMD_SUBMIT, GuiUtils.CMD_CANCEL });
    contents = GuiUtils.centerBottom(contents, buttons);
    dialog.getContentPane().add(contents);
    dialog.pack();
    GuiUtils.showInCenter(dialog);
    if (shouldDoBusyWait) {
        while (!done[0]) {
            Misc.sleep(100);
        }
    }
    return ok[0];
}

From source file:ui.frame.UILogin.java

public UILogin() {
    super("Login");

    Label l = new Label();

    setLayout(new BorderLayout());
    this.setPreferredSize(new Dimension(400, 300));

    Panel p = new Panel();

    loginPanel = p.createPanel(Layouts.grid, 4, 2);
    loginPanel.setBorder(new EmptyBorder(25, 25, 0, 25));
    lblUser = l.createLabel("Username:");
    lblPassword = l.createLabel("Password:");
    lblURL = l.createLabel("Server URL");
    lblBucket = l.createLabel("Bucket");

    tfURL = new JTextField();
    tfURL.setText("kaiup.kaisquare.com");
    tfBucket = new JTextField();
    PromptSupport.setPrompt("BucketName", tfBucket);
    tfUser = new JTextField();
    PromptSupport.setPrompt("Username", tfUser);
    pfPassword = new JPasswordField();
    PromptSupport.setPrompt("Password", pfPassword);

    buttonPanel = p.createPanel(Layouts.flow);
    buttonPanel.setBorder(new EmptyBorder(0, 0, 25, 0));
    Button b = new Button();
    JButton btnLogin = b.createButton("Login");
    JButton btnExit = b.createButton("Exit");
    btnLogin.setPreferredSize(new Dimension(150, 50));
    btnExit.setPreferredSize(new Dimension(150, 50));
    Component[] arrayBtn = { btnExit, btnLogin };
    p.addComponentsToPanel(buttonPanel, arrayBtn);

    Component[] arrayComponents = { lblURL, tfURL, lblBucket, tfBucket, lblUser, tfUser, lblPassword,
            pfPassword };/*ww w  . j a v  a2s . c  o  m*/
    p.addComponentsToPanel(loginPanel, arrayComponents);
    add(loginPanel, BorderLayout.CENTER);
    add(buttonPanel, BorderLayout.SOUTH);
    pack();
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setLocationRelativeTo(null);

    setVisible(true);
    btnLogin.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() {
                @Override
                protected Void doInBackground() throws Exception {
                    if (tfUser.getText().equals("") || String.valueOf(pfPassword.getPassword()).equals("")
                            || tfBucket.getText().equals("")) {
                        JOptionPane.showMessageDialog(Data.mainFrame, "Please fill up all the fields", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    } else {
                        String username = tfUser.getText();
                        String password = String.valueOf(pfPassword.getPassword());
                        Data.URL = Data.protocol + tfURL.getText();
                        Data.targetURL = Data.protocol + tfURL.getText() + "/api/" + tfBucket.getText() + "/";

                        String response = api.loginBucket(Data.targetURL, username, password);

                        try {

                            if (DesktopAppMain.checkResult(response)) {
                                JSONObject responseJSON = new JSONObject(response);
                                Data.sessionKey = responseJSON.get("session-key").toString();
                                response = api.getUserFeatures(Data.targetURL, Data.sessionKey);
                                if (checkFeatures(response)) {
                                    Data.mainFrame = new KAIQRFrame();
                                    Data.mainFrame.uiInventorySelect = new UIInventorySelect();
                                    Data.mainFrame.addPanel(Data.mainFrame.uiInventorySelect, "inventory");
                                    Data.mainFrame.showPanel("inventory");
                                    Data.mainFrame.pack();
                                    setVisible(false);
                                    Data.mainFrame.setVisible(true);

                                } else {
                                    JOptionPane.showMessageDialog(Data.loginFrame,
                                            "User does not have necessary features", "Error",
                                            JOptionPane.ERROR_MESSAGE);
                                }
                            } else {
                                JOptionPane.showMessageDialog(Data.loginFrame, "Wrong username/password",
                                        "Error", JOptionPane.ERROR_MESSAGE);
                            }

                        } catch (JSONException e1) {
                            e1.printStackTrace();
                        }
                    }

                    return null;
                }
            };

            Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource());
            final JDialog dialog = new JDialog(win, "Login", ModalityType.APPLICATION_MODAL);

            mySwingWorker.addPropertyChangeListener(new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if (evt.getPropertyName().equals("state")) {
                        if (evt.getNewValue() == SwingWorker.StateValue.DONE) {
                            dialog.dispose();
                        }
                    }
                }
            });

            mySwingWorker.execute();

            JProgressBar progressBar = new JProgressBar();
            progressBar.setIndeterminate(true);
            JPanel panel = new JPanel(new BorderLayout());
            panel.add(progressBar, BorderLayout.CENTER);
            panel.add(new JLabel("Logging in .........."), BorderLayout.PAGE_START);
            dialog.add(panel);
            dialog.pack();
            dialog.setBounds(50, 50, 300, 100);
            dialog.setLocationRelativeTo(Data.mainFrame);
            dialog.setVisible(true);
        }
    });

    btnExit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }

    });

}