Search in sources :

Example 36 with DefaultListModel

use of javax.swing.DefaultListModel in project beast-mcmc by beast-dev.

the class JListBinding method put.

public void put(IValidatable bean) {
    try {
        DefaultListModel model = new DefaultListModel();
        List<?> list = (List<?>) PropertyUtils.getProperty(bean, _property);
        if (list != null) {
            for (Object o : list) {
                model.addElement(o);
            }
        }
        _list.setModel(model);
    } catch (Exception e) {
        throw new BindingException(e);
    }
}
Also used : DefaultListModel(javax.swing.DefaultListModel) List(java.util.List) JList(javax.swing.JList) ArrayList(java.util.ArrayList)

Example 37 with DefaultListModel

use of javax.swing.DefaultListModel in project chipKIT32-MAX by chipKIT32.

the class JListBinding method get.

public void get(IValidatable bean) {
    try {
        DefaultListModel model = (DefaultListModel) _list.getModel();
        final int size = model.getSize();
        List list = new ArrayList(size);
        for (int i = 0; i < size; i++) {
            list.add(model.get(i));
        }
        PropertyUtils.setProperty(bean, _property, list);
    } catch (Exception e) {
        throw new BindingException(e);
    }
}
Also used : ArrayList(java.util.ArrayList) DefaultListModel(javax.swing.DefaultListModel) List(java.util.List) JList(javax.swing.JList) ArrayList(java.util.ArrayList)

Example 38 with DefaultListModel

use of javax.swing.DefaultListModel in project chipKIT32-MAX by chipKIT32.

the class JListBinding method put.

public void put(IValidatable bean) {
    try {
        DefaultListModel model = new DefaultListModel();
        List list = (List) PropertyUtils.getProperty(bean, _property);
        if (list != null) {
            for (Iterator iter = list.iterator(); iter.hasNext(); ) {
                model.addElement(iter.next());
            }
        }
        _list.setModel(model);
    } catch (Exception e) {
        throw new BindingException(e);
    }
}
Also used : Iterator(java.util.Iterator) DefaultListModel(javax.swing.DefaultListModel) List(java.util.List) JList(javax.swing.JList) ArrayList(java.util.ArrayList)

Example 39 with DefaultListModel

use of javax.swing.DefaultListModel in project processdash by dtuma.

the class UserGroupEditor method createUI.

private Component createUI() {
    // create the button panel
    JPanel buttonPanel = new JPanel(new GridLayout(2, 2, 5, 5));
    buttonPanel.add(new JButton(new AddAction()));
    buttonPanel.add(new JButton(copyAction = new CopyAction()));
    buttonPanel.add(new JButton(renameAction = new RenameAction()));
    buttonPanel.add(new JButton(deleteAction = new DeleteAction()));
    // read the known groups, and add them to a list
    List<UserGroup> allGroups = new ArrayList<UserGroup>();
    allGroups.addAll(UserGroupManager.getInstance().getGroups().values());
    Collections.sort(allGroups);
    groups = new DefaultListModel();
    for (UserGroup g : allGroups) groups.addElement(g);
    groupList = new JList(groups);
    groupList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    groupList.addListSelectionListener(new SelectionHandler());
    JScrollPane gsp = new JScrollPane(groupList);
    gsp.setPreferredSize(new Dimension(200, 300));
    // create an object for editing the members in the selected group
    memberList = new GroupMembershipSelector(readOnlyCode);
    JScrollPane msp = new JScrollPane(memberList);
    msp.setPreferredSize(new Dimension(200, 300));
    // create titles to display on the dialog
    JLabel groupTitle = new JLabel(resources.getString("User_Groups"));
    JLabel memberTitle = new JLabel(resources.getString("Selected_User_Group"));
    Font f = groupTitle.getFont();
    f = f.deriveFont(f.getSize2D() * 1.5f);
    groupTitle.setFont(f);
    memberTitle.setFont(f);
    Border b = BorderFactory.createMatteBorder(0, 0, 1, 0, Color.black);
    groupTitle.setBorder(b);
    memberTitle.setBorder(b);
    // arrange the components onto a panel
    GridBagLayout layout = new GridBagLayout();
    userInterface = new JPanel(layout);
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = c.gridy = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    layout.addLayoutComponent(groupTitle, c);
    userInterface.add(groupTitle);
    c.gridx = 2;
    Component comp = new JOptionPaneTweaker.MakeResizable();
    layout.addLayoutComponent(comp, c);
    userInterface.add(comp);
    c.gridx = 1;
    c.insets = new Insets(0, 10, 0, 0);
    layout.addLayoutComponent(memberTitle, c);
    userInterface.add(memberTitle);
    c.gridx = 0;
    c.gridy = 1;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(10, 20, 0, 0);
    layout.addLayoutComponent(buttonPanel, c);
    userInterface.add(buttonPanel);
    c.gridy = 2;
    c.weightx = c.weighty = 1.0;
    layout.addLayoutComponent(gsp, c);
    userInterface.add(gsp);
    c.gridx = c.gridy = 1;
    c.insets = new Insets(10, 30, 0, 0);
    c.gridheight = 2;
    layout.addLayoutComponent(msp, c);
    userInterface.add(msp);
    // load the preferred size of the window
    try {
        String[] size = Settings.getVal(SIZE_PREF).split(",");
        Dimension d = new Dimension(Integer.parseInt(size[0]), Integer.parseInt(size[1]));
        userInterface.setPreferredSize(d);
    } catch (Exception e) {
    }
    return userInterface;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JButton(javax.swing.JButton) ArrayList(java.util.ArrayList) DefaultListModel(javax.swing.DefaultListModel) Font(java.awt.Font) UserGroup(net.sourceforge.processdash.team.group.UserGroup) GridLayout(java.awt.GridLayout) Component(java.awt.Component) JScrollPane(javax.swing.JScrollPane) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) Border(javax.swing.border.Border) JList(javax.swing.JList)

Example 40 with DefaultListModel

use of javax.swing.DefaultListModel in project processdash by dtuma.

the class TaskScheduleSnapshotManager method createGui.

private void createGui(List<Metadata> snapshots) {
    GridBagLayout layout = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    setLayout(layout);
    int activePos = -1;
    snapshotModel = new DefaultListModel();
    for (Metadata snap : snapshots) {
        if (snap.getId().equals(activeSnapshotId))
            activePos = snapshotModel.getSize();
        snapshotModel.addElement(snap);
    }
    snapshotList = new JList(snapshotModel);
    snapshotList.setCellRenderer(new CellRenderer());
    if (activePos != -1)
        snapshotList.setSelectedIndex(activePos);
    c.gridx = c.gridy = 0;
    c.gridheight = 3;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(0, 0, 0, 10);
    add(new JScrollPane(snapshotList), c);
    c.gridx = c.gridheight = 1;
    c.weighty = c.gridy = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 0, 0, 0);
    add(new JButton(new EditAction()), c);
    c.weighty = c.gridy = 1;
    add(new JButton(new DeleteAction()), c);
    c.weighty = 0;
    c.gridy = 2;
    add(new JButton(new SelectAction()), c);
}
Also used : JScrollPane(javax.swing.JScrollPane) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) EVMetadata(net.sourceforge.processdash.ev.EVMetadata) Metadata(net.sourceforge.processdash.ev.EVSnapshot.Metadata) JButton(javax.swing.JButton) DefaultListModel(javax.swing.DefaultListModel) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) JList(javax.swing.JList)

Aggregations

DefaultListModel (javax.swing.DefaultListModel)41 JList (javax.swing.JList)21 ArrayList (java.util.ArrayList)16 JScrollPane (javax.swing.JScrollPane)13 List (java.util.List)8 JButton (javax.swing.JButton)8 ActionEvent (java.awt.event.ActionEvent)5 ActionListener (java.awt.event.ActionListener)5 JPanel (javax.swing.JPanel)5 Conditional (jmri.Conditional)5 Dimension (java.awt.Dimension)4 GridBagConstraints (java.awt.GridBagConstraints)4 GridBagLayout (java.awt.GridBagLayout)4 Insets (java.awt.Insets)4 Logix (jmri.Logix)4 Component (java.awt.Component)3 JLabel (javax.swing.JLabel)3 SensorGroupConditional (jmri.implementation.SensorGroupConditional)3 FormBuilder (com.jgoodies.forms.builder.FormBuilder)2 FormLayout (com.jgoodies.forms.layout.FormLayout)2