Search in sources :

Example 1 with ListModel

use of javax.swing.ListModel in project OpenAM by OpenRock.

the class ListJPanel method addCategory.

public void addCategory(ImageListEntry entry) {
    ListModel model = categoryjList.getModel();
    if (model instanceof DefaultListModel) {
        ((DefaultListModel) model).addElement(entry);
    } else {
        DefaultListModel newModel = new DefaultListModel();
        newModel.addElement(entry);
        categoryjList.setModel(newModel);
    }
}
Also used : DefaultListModel(javax.swing.DefaultListModel) ListModel(javax.swing.ListModel) DefaultListModel(javax.swing.DefaultListModel)

Example 2 with ListModel

use of javax.swing.ListModel in project pcgen by PCGen.

the class EncounterPlugin method mouseClicked.

@Override
public void mouseClicked(MouseEvent evt) {
    if (evt.getSource() == theView.getLibraryCreatures()) {
        if (evt.getClickCount() == 2) {
            int index = theView.getLibraryCreatures().locationToIndex(evt.getPoint());
            ListModel dlm = theView.getLibraryCreatures().getModel();
            Object item = dlm.getElementAt(index);
            theView.getLibraryCreatures().ensureIndexIsVisible(index);
            theModel.addElement(item);
            updateUI();
        }
    } else if (evt.getSource() == theView.getEncounterCreatures()) {
        try {
            if (evt.getClickCount() == 2) {
                int index = theView.getEncounterCreatures().locationToIndex(evt.getPoint());
                ListModel dlm = theView.getEncounterCreatures().getModel();
                Object item = dlm.getElementAt(index);
                theView.getEncounterCreatures().ensureIndexIsVisible(index);
                theModel.removeElement(item);
                updateUI();
            }
        } catch (Exception e) {
        //TODO: Should this really be ignored?
        }
    }
}
Also used : ListModel(javax.swing.ListModel) FileNotFoundException(java.io.FileNotFoundException)

Example 3 with ListModel

use of javax.swing.ListModel in project OpenAM by OpenRock.

the class CheckBoxJPanel method addTest.

public void addTest(CheckBoxListEntry entry) {
    ListModel model = checkBoxjList.getModel();
    if (model instanceof DefaultListModel) {
        ((DefaultListModel) model).addElement(entry);
    } else {
        DefaultListModel newModel = new DefaultListModel();
        newModel.addElement(entry);
        checkBoxjList.setModel(newModel);
    }
}
Also used : DefaultListModel(javax.swing.DefaultListModel) ListModel(javax.swing.ListModel) DefaultListModel(javax.swing.DefaultListModel)

Example 4 with ListModel

use of javax.swing.ListModel in project adempiere by adempiere.

the class VTreeMaintenance method propertyChange.

//	valueChanged
/**
	 * 	VTreePanel Changed
	 *	@param e event
	 */
public void propertyChange(PropertyChangeEvent e) {
    MTreeNode tn = (MTreeNode) e.getNewValue();
    log.info(tn.toString());
    if (tn == null)
        return;
    ListModel model = centerList.getModel();
    int size = model.getSize();
    int index = -1;
    for (index = 0; index < size; index++) {
        ListItem item = (ListItem) model.getElementAt(index);
        if (item.id == tn.getNode_ID())
            break;
    }
    centerList.setSelectedIndex(index);
}
Also used : MTreeNode(org.compiere.model.MTreeNode) DefaultListModel(javax.swing.DefaultListModel) ListModel(javax.swing.ListModel)

Example 5 with ListModel

use of javax.swing.ListModel in project adempiere by adempiere.

the class VTreeMaintenance method action_treeAddAll.

//	action_treeDelete
/**
	 * 	Action: Add All Nodes to Tree
	 */
private void action_treeAddAll() {
    log.info("");
    ListModel model = centerList.getModel();
    int size = model.getSize();
    int index = -1;
    for (index = 0; index < size; index++) {
        ListItem item = (ListItem) model.getElementAt(index);
        action_treeAdd(item);
    }
}
Also used : DefaultListModel(javax.swing.DefaultListModel) ListModel(javax.swing.ListModel)

Aggregations

ListModel (javax.swing.ListModel)6 DefaultListModel (javax.swing.DefaultListModel)5 FileNotFoundException (java.io.FileNotFoundException)1 MTreeNode (org.compiere.model.MTreeNode)1