List of usage examples for javax.swing JDialog JDialog
public JDialog(Window owner, String title, Dialog.ModalityType modalityType)
From source file:org.nuclos.client.ui.collect.CollectController.java
/** * alternative entry point: lookup a <code>Collectable</code> (in a foreign entity). */// w w w.j a va 2 s . com public void runLookupCollectable(final ICollectableListOfValues clctlovSource) throws CommonBusinessException { // show the internal frame in the front of the modal layer: final MainFrameTab ifrm = this.getTab(); ifrm.setVisible(true); if (!clctlovSource.isSearchComponent()) { String label = getSpringLocaleDelegate().getMessage("CollectController.41", "Auswahl bernehmen"); String description = getSpringLocaleDelegate().getMessage("CollectController.42", "Findet die bernahme in einem Unterformular statt werden mittels Mehrfachauswahl zustzliche Datenstze im Unterformular erzeugt."); if (clctlovSource instanceof CollectableListOfValues) { final CollectableListOfValues clov = (CollectableListOfValues) clctlovSource; if (clov.getValueListProvider() instanceof DatasourceBasedCollectableFieldsProvider) { ss.setValueListProviderDatasource( ((DatasourceBasedCollectableFieldsProvider) clov.getValueListProvider()) .getDatasourceVO()); ss.setValueListProviderDatasourceParameter( ((DatasourceBasedCollectableFieldsProvider) clov.getValueListProvider()) .getValueListParameter()); } else if (clov .getValueListProvider() instanceof CollectableFieldsProviderCache.CachingCollectableFieldsProvider) { CollectableFieldsProvider delegate = ((CollectableFieldsProviderCache.CachingCollectableFieldsProvider) clov .getValueListProvider()).getDelegate(); if (delegate instanceof DatasourceBasedCollectableFieldsProvider) { ss.setValueListProviderDatasource( ((DatasourceBasedCollectableFieldsProvider) delegate).getDatasourceVO()); ss.setValueListProviderDatasourceParameter( ((DatasourceBasedCollectableFieldsProvider) delegate).getValueListParameter()); } } } else if (clctlovSource instanceof EntityListOfValues) { label = getSpringLocaleDelegate().getMessage("CollectController.lookup.generation", "Objekte ausw\u00e4hlen"); description = getSpringLocaleDelegate().getMessage( "CollectController.lookup.generation.description", "Parameterobjekte fr die Objektgenerierung ausw\u00e4hlen."); } final JMenuItem miPopupApplySelection = new JMenuItem(label); miPopupApplySelection.setToolTipText(description); getResultPanel().popupmenuRow.removeAll();//.addSeparator(); getResultPanel().popupmenuRow.add(miPopupApplySelection); miPopupApplySelection.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { acceptLookedUpCollectable(clctlovSource); getTab().dispose(); } }); } // remove mouse listener for double click in table: getResultPanel().removeDoubleClickMouseListener(this.getMouseListenerForTableDoubleClick()); // add alternative mouse listener for foreign key lookup: foreignKeyMouseListenerForTableDoubleClick = new MouseAdapter() { @Override public void mouseClicked(MouseEvent ev) { if (SwingUtilities.isLeftMouseButton(ev) && ev.getClickCount() == 2) { int iRow = getResultTable().rowAtPoint(ev.getPoint()); if (iRow >= 0 && iRow < getResultTable().getRowCount()) { getResultTable().getSelectionModel().setSelectionInterval(iRow, iRow); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { acceptLookedUpCollectable(clctlovSource); getTab().dispose(); } }); } } } }; getResultPanel().addDoubleClickMouseListener(foreignKeyMouseListenerForTableDoubleClick); // @see NUCLOS-432 //getResultTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); getResultTable().getActionMap().put(KeyBindingProvider.EDIT_2.getKey(), new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { acceptLookedUpCollectable(clctlovSource); getTab().dispose(); } }); if (this.isSearchPanelAvailable()) { if (ss.getValueListProviderDatasource() != null) { this.runViewAll(); } else { this.runSearch(); } } else { this.runViewAll(); } final Boolean modalLookup = (Boolean) clctlovSource .getProperty(ICollectableListOfValues.PROPERTY_MODAL_LOOKUP); if (Boolean.TRUE.equals(modalLookup)) { JDialog d = new JDialog(Main.getInstance().getMainFrame(), ifrm.getTitle(), true); FrameUtils.externalizeIntoWindow(ifrm, d); d.pack(); d.setVisible(true); } }
From source file:org.springframework.richclient.dialog.ApplicationDialog.java
/** * Construct the visual dialog frame on which the content needs to be added. *//*from www. j av a 2 s . c o m*/ private void constructDialog() { if (getParentWindow() instanceof Frame) { dialog = new JDialog((Frame) getParentWindow(), getTitle(), modal); } else { dialog = new JDialog((Dialog) getParentWindow(), getTitle(), modal); } dialog.getContentPane().setLayout(new BorderLayout()); dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); dialog.setResizable(resizable); initStandardCommands(); addCancelByEscapeKey(); }
From source file:pcgen.gui2.PCGenFrame.java
private void showLicenseDialog(String title, String htmlString) { if (htmlString == null) { htmlString = LanguageBundle.getString("in_licNoInfo"); //$NON-NLS-1$ }// ww w. j a v a 2 s.com final PropertyContext context = PCGenSettings.OPTIONS_CONTEXT; final JDialog aFrame = new JDialog(this, title, true); final JButton jClose = new JButton(LanguageBundle.getString("in_close")); //$NON-NLS-1$ jClose.setMnemonic(LanguageBundle.getMnemonic("in_mn_close")); //$NON-NLS-1$ final JPanel jPanel = new JPanel(); final JCheckBox jCheckBox = new JCheckBox(LanguageBundle.getString("in_licShowOnLoad")); //$NON-NLS-1$ jPanel.add(jCheckBox); jCheckBox.setSelected(context.getBoolean(PCGenSettings.OPTION_SHOW_LICENSE)); jCheckBox.addItemListener( evt -> context.setBoolean(PCGenSettings.OPTION_SHOW_LICENSE, jCheckBox.isSelected())); jPanel.add(jClose); jClose.addActionListener(evt -> aFrame.dispose()); HtmlPanel htmlPanel = new HtmlPanel(); HtmlRendererContext theRendererContext = new SimpleHtmlRendererContext(htmlPanel, new SimpleUserAgentContext()); htmlPanel.setHtml(htmlString, "", theRendererContext); aFrame.getContentPane().setLayout(new BorderLayout()); aFrame.getContentPane().add(htmlPanel, BorderLayout.CENTER); aFrame.getContentPane().add(jPanel, BorderLayout.SOUTH); aFrame.setSize(new Dimension(700, 500)); aFrame.setLocationRelativeTo(this); Utility.setComponentRelativeLocation(this, aFrame); aFrame.getRootPane().setDefaultButton(jClose); Utility.installEscapeCloseOperation(aFrame); aFrame.setVisible(true); }
From source file:pcgen.gui2.PCGenFrame.java
private void showMatureDialog(String text) { Logging.errorPrint("Warning: The following datasets contains mature themes. User discretion is advised."); Logging.errorPrint(text);/*w ww .java 2 s .c om*/ final JDialog aFrame = new JDialog(this, LanguageBundle.getString("in_matureTitle"), true); final JPanel jPanel1 = new JPanel(); final JPanel jPanel3 = new JPanel(); final JLabel jLabel1 = new JLabel(LanguageBundle.getString("in_matureWarningLine1"), //$NON-NLS-1$ SwingConstants.CENTER); final JLabel jLabel2 = new JLabel(LanguageBundle.getString("in_matureWarningLine2"), //$NON-NLS-1$ SwingConstants.CENTER); final JCheckBox jCheckBox1 = new JCheckBox(LanguageBundle.getString("in_licShowOnLoad")); //$NON-NLS-1$ final JButton jClose = new JButton(LanguageBundle.getString("in_close")); //$NON-NLS-1$ jClose.setMnemonic(LanguageBundle.getMnemonic("in_mn_close")); //$NON-NLS-1$ jPanel1.setLayout(new BorderLayout()); jPanel1.add(jLabel1, BorderLayout.NORTH); jPanel1.add(jLabel2, BorderLayout.SOUTH); HtmlPanel htmlPanel = new HtmlPanel(); HtmlRendererContext theRendererContext = new SimpleHtmlRendererContext(htmlPanel, new SimpleUserAgentContext()); htmlPanel.setHtml(text, "", theRendererContext); jPanel3.add(jCheckBox1); jPanel3.add(jClose); final PropertyContext context = PCGenSettings.OPTIONS_CONTEXT; jCheckBox1.setSelected(context.getBoolean(PCGenSettings.OPTION_SHOW_MATURE_ON_LOAD)); jClose.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { aFrame.dispose(); } }); jCheckBox1.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent evt) { context.setBoolean(PCGenSettings.OPTION_SHOW_MATURE_ON_LOAD, jCheckBox1.isSelected()); } }); aFrame.getContentPane().setLayout(new BorderLayout()); aFrame.getContentPane().add(jPanel1, BorderLayout.NORTH); aFrame.getContentPane().add(htmlPanel, BorderLayout.CENTER); aFrame.getContentPane().add(jPanel3, BorderLayout.SOUTH); aFrame.setSize(new Dimension(456, 176)); Utility.setComponentRelativeLocation(this, aFrame); aFrame.setVisible(true); }
From source file:plugins.tprovoost.Microscopy.MicroManagerForIcy.MMMainFrame.java
/** * Create an error dialog concerning DLL issues with Micro-Manager. * /*from w ww .ja va 2 s.c o m*/ * @return Returns the dialog. */ private JDialog createDLLErrorDialog() { MainFrame mainFrame = Icy.getMainInterface().getMainFrame(); // Dialog frame to be returned final JDialog dialog = new JDialog(mainFrame, "Loading Error", true); // main panel of the dialog JPanel panel_main = new JPanel(); panel_main.setLayout(new BorderLayout()); JLabel lbl_html = new JLabel("<html>" + "<h2>Unable to load library</h2>" + "<br/><b>What happened ?</b>" + "<p>The library is a file used by Manager to interact with the devices. Each device needs a specific file in order <br/>" + "to work properly with the system. If only one file is missing, this error occurs.</p>" + "<b>To avoid getting this problem again, please acknowledge the following steps: </b>" + "<ol><li>Do you have Micro-Manager 1.4 installed ? If not, please install it via the button below.</li>" + "<li>Check the application directory of Icy. You should find a file named: " + "<ul><li>on Windows: MMCoreJ_wrap</li><li>on Mac: libMMCoreJ_wrap</li></ul>" + "<li>Plus : you should have a file for each of your devices starting with the name:" + "<ul><li>on Windows: mmgr_dal_</li><li>on Mac: libmmgr_dal_</li></ul>" + "<li>If you don't have these files, please copy (not move) them from the Manager application directory<br/>" + "to your Icy application directory.</li></ol></html>"); panel_main.add(lbl_html, BorderLayout.CENTER); panel_main.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20)); JPanel panel_buttons = new JPanel(); panel_buttons.setLayout(new BoxLayout(panel_buttons, BoxLayout.X_AXIS)); panel_buttons.add(Box.createHorizontalGlue()); JButton btn_link = new JButton(); btn_link.setText("Download Micro-Manager 1.4.14"); btn_link.setBackground(Color.WHITE); btn_link.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetworkUtil .openBrowser("http://valelab.ucsf.edu/~MM/MMwiki/index.php/Micro-Manager_Version_Archive"); } }); panel_buttons.add(btn_link); JButton btn_ok = new JButton("OK"); btn_ok.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); } }); panel_buttons.add(btn_ok); panel_main.add(panel_buttons, BorderLayout.SOUTH); dialog.add(panel_main); dialog.pack(); dialog.setLocation((int) mainFrame.getSize().getWidth() / 2 - dialog.getWidth() / 2, (int) mainFrame.getSize().getHeight() / 2 - dialog.getHeight() / 2); return dialog; }
From source file:ro.nextreports.designer.NextReportsServerRequest.java
public NextReportsServerRequest() { try {/*from w w w. j a v a2s . c om*/ SwingUtilities.invokeLater(new Runnable() { @Override public void run() { String message = I18NSupport.getString("download"); dialog = new JDialog(Globals.getMainFrame(), message, true); loginPanel = new PublishLoginWizardPanel(null) { public boolean hasNext() { return false; } public boolean canFinish() { return true; } public boolean validateFinish(java.util.List<String> messages) { boolean ok = validateNext(messages); return ok; } }; Wizard wizard = new Wizard(loginPanel); wizard.getContext().setAttribute(PublishWizard.MAIN_FRAME, dialog); wizard.addWizardListener(NextReportsServerRequest.this); dialog.setContentPane(wizard); dialog.setSize(400, 340); dialog.setLocationRelativeTo(null); dialog.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { super.windowClosing(e); } }); dialog.setVisible(true); } }); } catch (Exception e) { e.printStackTrace(); LOG.error(e.getMessage(), e); } }
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 a v a 2 s. c o m 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: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 };/*www . j ava2 s . co 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); } }); }
From source file:ui.panel.UIAccessKeySelect.java
public void runaccessKeySelect() { getAccessKeyData();/*from w w w . ja va 2 s . c om*/ Panel p = new Panel(); Button b = new Button(); Label l = new Label(); setLayout(new BorderLayout()); JPanel pnlInstruction = p.createPanel(Layouts.flow); JLabel lblInstruction = l.createLabel("Access Keys"); pnlInstruction.setBackground(CustomColor.LightBlue.returnColor()); lblInstruction.setForeground(Color.white); lblInstruction.setFont(new Font("San Serif", Font.PLAIN, 18)); pnlInstruction.add(lblInstruction); JPanel pnlBucketList = p.createPanel(Layouts.border); listBucket.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scrollBucket = new JScrollPane(listBucket); Component[] BucketListComponents = { scrollBucket }; pnlBucketList.add(scrollBucket, BorderLayout.CENTER); JPanel pnlButtons = p.createPanel(Layouts.flow); JButton btnBack = b.createButton("Back"); JButton btnSelectElements = b.createButton("Next"); JButton btnAdd = b.createButton("Generate Access Key"); JButton btnRefresh = b.createButton("Refresh"); pnlButtons.add(btnBack); pnlButtons.add(btnAdd); pnlButtons.add(btnRefresh); pnlButtons.add(btnSelectElements); add(pnlInstruction, BorderLayout.NORTH); add(pnlBucketList, BorderLayout.CENTER); add(pnlButtons, BorderLayout.SOUTH); btnBack.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Data.mainFrame.showPanel("license"); } }); btnRefresh.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getAccessKeyData(); } }); btnAdd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Data.mainFrame.uiGenerateKey = new UIGenerateKey(); Data.mainFrame.addPanel(Data.mainFrame.uiGenerateKey, "generateKey"); Data.mainFrame.pack(); Data.mainFrame.showPanel("generateKey"); } }); btnSelectElements.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { int selected = listBucket.getSelectedRow(); if (selected != -1) { Data.accessKey = (String) listBucket.getModel().getValueAt(selected, 0); Data.mainFrame.qrGenerator = new JavaQR(); Data.mainFrame.pack(); Data.mainFrame.addPanel(Data.mainFrame.qrGenerator, "generateQR"); Data.mainFrame.showPanel("generateQR"); } else { JOptionPane.showMessageDialog(Data.mainFrame, "Please Select Access Key", "Error", JOptionPane.ERROR_MESSAGE); } return null; } }; Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource()); final JDialog dialog = new JDialog(win, "Loading", 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("Generating QR Code......."), BorderLayout.PAGE_START); dialog.add(panel); dialog.pack(); dialog.setBounds(50, 50, 300, 100); dialog.setLocationRelativeTo(Data.mainFrame); dialog.setVisible(true); } }); }
From source file:ui.panel.UIBucketSelect.java
public void runBucketSelect() { Panel p = new Panel(); Button b = new Button(); Label l = new Label(); setLayout(new BorderLayout()); JPanel pnlInstruction = p.createPanel(Layouts.flow); JLabel lblInstruction = l.createLabel("Bucket List"); pnlInstruction.setBackground(CustomColor.LightBlue.returnColor()); lblInstruction.setForeground(Color.white); lblInstruction.setFont(new Font("San Serif", Font.PLAIN, 18)); pnlInstruction.add(lblInstruction);/*from ww w . j a va 2s. c o m*/ JPanel pnlBucketList = p.createPanel(Layouts.border); listBucket.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scrollBucket = new JScrollPane(listBucket); scrollBucket.setPreferredSize(new Dimension(300, 150)); pnlBucketList.add(scrollBucket, BorderLayout.CENTER); JPanel pnlButtons = p.createPanel(Layouts.flow); JButton btnBack = b.createButton("Back"); JButton btnSelectElements = b.createButton("Next"); JButton btnRefresh = b.createButton("Refresh Bucket List"); pnlButtons.add(btnBack); pnlButtons.add(btnRefresh); pnlButtons.add(btnSelectElements); add(pnlInstruction, BorderLayout.NORTH); add(pnlBucketList, BorderLayout.CENTER); add(pnlButtons, BorderLayout.SOUTH); setVisible(true); btnRefresh.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getBucketData(); } }); btnSelectElements.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { int selected = listBucket.getSelectedRow(); if (selected == -1) { JOptionPane.showMessageDialog(Data.mainFrame, "Please Select a Bucket", "Error", JOptionPane.ERROR_MESSAGE); } else { Data.bucketID = (int) listBucket.getModel().getValueAt(selected, 0); Data.mainFrame.addPanel(Data.mainFrame.uiLicenseDetail = new UILicenseDetail(), "license"); Data.mainFrame.pack(); Data.mainFrame.showPanel("license"); } return null; } }; Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource()); final JDialog dialog = new JDialog(win, "Loading", 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("Retrieving Licenses......."), BorderLayout.PAGE_START); dialog.add(panel); dialog.pack(); dialog.setBounds(50, 50, 300, 100); dialog.setLocationRelativeTo(Data.mainFrame); dialog.setVisible(true); } }); btnBack.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); Data.mainFrame.showPanel("inventory"); } }); }