List of usage examples for javax.swing JCheckBox isSelected
public boolean isSelected()
From source file:unikn.dbis.univis.navigation.tree.VTree.java
/** * TODO: document me!!!// w w w. j av a 2 s . com * * @param p */ public void showPopupMenu(Point p) { // Remove all items from popup menu. popupMenu.removeAll(); Object o = getLastSelectedPathComponent(); if (o instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) o; Object userObject = node.getUserObject(); if (userObject instanceof VDimension) { VDimension dimension = (VDimension) userObject; try { Point p2 = new Point(p); SwingUtilities.convertPointToScreen(p2, this); final FilterItemContainer container = createFilterContainer(dimension, p2); if (!container.isEmpty()) { /* JLabel header = new JLabel(MessageResolver.getMessage("data_reference." + dimension.getI18nKey())); Font font = header.getFont(); header.setFont(new Font(font.getFontName(), Font.BOLD, font.getSize() + 2)); popupMenu.add(header); popupMenu.add(new JPopupMenu.Separator()); */ popupMenu = new FilterPopupMenu( MessageResolver.getMessage("data_reference." + dimension.getI18nKey())); final JCheckBox button = new JCheckBox("Check/Uncheck all"); button.setSelected(container.isAllChecked()); button.addActionListener(new ActionListener() { /** * Invoked when an action occurs. */ public void actionPerformed(ActionEvent e) { for (Component c : container.getComponents()) { if (c instanceof VBidirectionalBrowsingItem) { ((VBidirectionalBrowsingItem) c).getCheckBox() .setChecked(button.isSelected()); } } } }); popupMenu.add(button); popupMenu.add(new JPopupMenu.Separator()); popupMenu.add(container); JButton view = new JButton(MessageResolver.getMessage("filtering"), VIcons.FILTER); view.addActionListener(new ActionListener() { /** * Invoked when an action occurs. */ public void actionPerformed(ActionEvent e) { popupMenu.setVisible(false); } }); popupMenu.add(new JPopupMenu.Separator()); popupMenu.add(view); popupMenu.show(VTree.this, (int) p.getX(), (int) p.getY()); } else { JOptionPane.showMessageDialog(VTree.this.getParent().getParent().getParent(), MessageResolver.getMessage("no_items_found"), MessageResolver.getMessage("error_message"), JOptionPane.ERROR_MESSAGE); } } catch (SQLException sqle) { VExplorer.publishException(sqle); if (LOG.isErrorEnabled()) { LOG.error(sqle.getMessage(), sqle); } } } } }
From source file:xtrememp.update.SoftwareUpdate.java
public static void checkForUpdates(final boolean showDialogs) { checkForUpdatesWorker = new SwingWorker<Version, Void>() { @Override/* w w w . jav a 2s.c om*/ protected Version doInBackground() throws Exception { logger.debug("checkForUpdates: started..."); long startTime = System.currentTimeMillis(); Version version = getLastVersion(new URL(updatesURL)); if (showDialogs) { // Simulate (if needed) a delay of 2 sec max to let the user cancel the task. long delayTime = System.currentTimeMillis() - startTime - 2000; if (delayTime > 0) { Thread.sleep(delayTime); } } return version; } @Override protected void done() { logger.debug("checkForUpdates: done"); if (checkForUpdatesDialog != null && checkForUpdatesDialog.isVisible()) { checkForUpdatesDialog.dispose(); } if (!isCancelled()) { try { newerVersion = get(); if (newerVersion != null && newerVersion.compareTo(currentVersion) == 1) { logger.debug("checkForUpdates: currentVersion = {}", currentVersion); logger.debug("checkForUpdates: newerVersion = {}", newerVersion); logger.debug("SoftwareUpdate::checkForUpdates: updates found"); Object[] options = { tr("Button.Cancel") }; Desktop desktop = null; if (Desktop.isDesktopSupported()) { desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.BROWSE)) { options = new Object[] { tr("Button.Download"), tr("Button.Cancel") }; } } JPanel panel = new JPanel(new BorderLayout(0, 10)); panel.add(new JLabel("<html>" + tr("Dialog.SoftwareUpdate.UpdatesFound") + " (" + newerVersion + ")</html>"), BorderLayout.CENTER); JCheckBox hideCheckBox = null; if (Settings.isAutomaticUpdatesEnabled()) { hideCheckBox = new JCheckBox( tr("Dialog.SoftwareUpdate.DisableAutomaticCheckForUpdates")); panel.add(hideCheckBox, BorderLayout.SOUTH); } int option = JOptionPane.showOptionDialog(XtremeMP.getInstance().getMainFrame(), panel, tr("Dialog.SoftwareUpdate"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (hideCheckBox != null) { Settings.setAutomaticUpdatesEnabled(!hideCheckBox.isSelected()); } if ((options.length == 2) && (option == JOptionPane.OK_OPTION)) { try { URL url = new URL(newerVersion.getDownloadURL()); desktop.browse(url.toURI()); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } } } else { logger.debug("checkForUpdates: no updates found"); if (showDialogs) { JOptionPane.showMessageDialog(XtremeMP.getInstance().getMainFrame(), tr("Dialog.SoftwareUpdate.NoUpdatesFound"), tr("Dialog.SoftwareUpdate"), JOptionPane.INFORMATION_MESSAGE); } } } catch (Exception ex) { logger.error(ex.getMessage(), ex); if (showDialogs) { JOptionPane.showMessageDialog(XtremeMP.getInstance().getMainFrame(), tr("Dialog.SoftwareUpdate.ConnectionFailure"), tr("Dialog.SoftwareUpdate"), JOptionPane.INFORMATION_MESSAGE); } } } } }; checkForUpdatesWorker.execute(); }