Example usage for javax.swing JCheckBox putClientProperty

List of usage examples for javax.swing JCheckBox putClientProperty

Introduction

In this page you can find the example usage for javax.swing JCheckBox putClientProperty.

Prototype

public final void putClientProperty(Object key, Object value) 

Source Link

Document

Adds an arbitrary key/value "client property" to this component.

Usage

From source file:com.github.alexfalappa.nbspringboot.projects.initializr.BootDependenciesPanel.java

private JCheckBox checkBoxForNode(String group, JsonNode dn) {
    final String name = dn.path("name").asText();
    final String id = dn.path("id").asText();
    final String description = dn.path("description").asText();
    final String versRange = dn.path("versionRange").asText();
    JCheckBox ch = new JCheckBox(name);
    ch.setName(id);//from  w w w  .j a v a  2s  .c  o  m
    ch.putClientProperty(PROP_VERSION_RANGE, versRange);
    ch.putClientProperty(PROP_DESCRIPTION, description);
    if (!chkBoxesMap.containsKey(group)) {
        chkBoxesMap.put(group, new ArrayList<JCheckBox>());
    }
    chkBoxesMap.get(group).add(ch);
    return ch;
}

From source file:com.adito.upgrade.GUIUpgrader.java

void addUpgradeSelectionComponent() {
    upgradeSelectionPanel.invalidate();//from  ww  w. j av a2  s . c  om
    upgradeSelectionPanel.removeAll();
    for (Iterator i = upgrades.iterator(); i.hasNext();) {
        AbstractDatabaseUpgrade upgrade = (AbstractDatabaseUpgrade) i.next();
        JCheckBox box = new JCheckBox(upgrade.getName());
        box.setSelected(upgrade.isSelectedByDefault());
        box.setToolTipText(upgrade.getDescription());
        upgradeSelectionPanel.add(box);
        box.putClientProperty("upgrade", upgrade);
    }
    upgradeSelectionPanel.validate();
}

From source file:org.formic.wizard.step.gui.FeatureListStep.java

/**
 * {@inheritDoc}//from   ww w. ja v a 2 s .  c om
 * @see org.formic.wizard.step.GuiStep#init()
 */
public Component init() {
    featureInfo = new JEditorPane("text/html", StringUtils.EMPTY);
    featureInfo.setEditable(false);
    featureInfo.addHyperlinkListener(new HyperlinkListener());

    Feature[] features = provider.getFeatures();
    JTable table = new JTable(features.length, 1) {
        private static final long serialVersionUID = 1L;

        public Class getColumnClass(int column) {
            return getValueAt(0, column).getClass();
        }

        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    table.setBackground(new javax.swing.JList().getBackground());

    GuiForm form = createForm();

    for (int ii = 0; ii < features.length; ii++) {
        final Feature feature = (Feature) features[ii];
        final JCheckBox box = new JCheckBox();

        String name = getName() + '.' + feature.getKey();
        form.bind(name, box);

        box.putClientProperty("feature", feature);
        featureMap.put(feature.getKey(), box);

        if (feature.getInfo() == null) {
            feature.setInfo(Installer.getString(getName() + "." + feature.getKey() + ".html"));
        }
        feature.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent event) {
                if (Feature.ENABLED_PROPERTY.equals(event.getPropertyName())) {
                    if (box.isSelected() != feature.isEnabled()) {
                        box.setSelected(feature.isEnabled());
                    }
                }
            }
        });

        box.setText(Installer.getString(name));
        box.setBackground(table.getBackground());
        if (!feature.isAvailable()) {
            box.setSelected(false);
            box.setEnabled(false);
        }
        table.setValueAt(box, ii, 0);
    }

    FeatureListMouseListener mouseListener = new FeatureListMouseListener();
    for (int ii = 0; ii < features.length; ii++) {
        Feature feature = (Feature) features[ii];
        if (feature.isEnabled() && feature.isAvailable()) {
            JCheckBox box = (JCheckBox) featureMap.get(feature.getKey());
            box.setSelected(true);
            mouseListener.processDependencies(feature);
            mouseListener.processExclusives(feature);
        }
    }

    table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setShowHorizontalLines(false);
    table.setShowVerticalLines(false);
    table.setDefaultRenderer(JCheckBox.class, new ComponentTableCellRenderer());

    table.addKeyListener(new FeatureListKeyListener());
    table.addMouseListener(mouseListener);
    table.getSelectionModel().addListSelectionListener(new FeatureListSelectionListener(table));

    table.setRowSelectionInterval(0, 0);

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    JPanel container = new JPanel(new BorderLayout());
    container.add(table, BorderLayout.CENTER);
    panel.add(new JScrollPane(container), BorderLayout.CENTER);
    JScrollPane infoScroll = new JScrollPane(featureInfo);
    infoScroll.setMinimumSize(new Dimension(0, 50));
    infoScroll.setMaximumSize(new Dimension(0, 50));
    infoScroll.setPreferredSize(new Dimension(0, 50));
    panel.add(infoScroll, BorderLayout.SOUTH);

    return panel;
}

From source file:storybook.model.EntityUtil.java

public static List<JCheckBox> createCategoryCheckBoxes(MainFrame mainFrame, ActionListener comp) {
    List<JCheckBox> list = new ArrayList<>();
    BookModel model = mainFrame.getBookModel();
    Session session = model.beginTransaction();
    CategoryDAOImpl dao = new CategoryDAOImpl(session);
    List<Category> categories = dao.findAllOrderBySort();
    model.commit();/*from w ww .j a  v a 2s. c o  m*/
    for (Category category : categories) {
        JCheckBox cb = new JCheckBox(category.getName());
        cb.putClientProperty(SbConstants.ComponentName.CB_CATEGORY, category);
        cb.setOpaque(false);
        cb.addActionListener(comp);
        cb.setSelected(true);
        list.add(cb);
    }
    return list;
}

From source file:storybook.model.EntityUtil.java

public static List<JCheckBox> createPersonCheckBoxes(MainFrame mainFrame, List<JCheckBox> cbl,
        ActionListener comp) {/*w w w  .j  a v  a 2 s .co m*/
    List<JCheckBox> list = new ArrayList<>();
    BookModel model = mainFrame.getBookModel();
    Session session = model.beginTransaction();
    PersonDAOImpl dao = new PersonDAOImpl(session);
    for (JCheckBox cb : cbl) {
        if (cb.isSelected()) {
            Category category = (Category) cb.getClientProperty(SbConstants.ComponentName.CB_CATEGORY);
            List<Person> persons = dao.findByCategory(category);
            for (Person person : persons) {
                JCheckBox cbPerson = new JCheckBox(person.getFullNameAbbr());
                cbPerson.setOpaque(false);
                cbPerson.putClientProperty(SbConstants.ComponentName.CB_PERSON, person);
                cbPerson.addActionListener(comp);
                list.add(cbPerson);
            }
        }
    }
    model.commit();
    return list;
}

From source file:storybook.model.EntityUtil.java

public static List<JCheckBox> createItemCheckBoxes(MainFrame m, ActionListener comp) {
    List<JCheckBox> list = new ArrayList<>();
    BookModel model = m.getBookModel();/*from  w  w w.  j a va2  s.  c  om*/
    Session session = model.beginTransaction();
    ItemDAOImpl dao = new ItemDAOImpl(session);
    List<Item> items = dao.findAll();
    for (Item item : items) {
        JCheckBox cbItem = new JCheckBox(item.getName());
        cbItem.setOpaque(false);
        cbItem.putClientProperty(SbConstants.ComponentName.CB_ITEM, item);
        cbItem.addActionListener(comp);
        list.add(cbItem);
    }
    model.commit();
    return list;
}