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);
}
}
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);
}
}
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);
}
}
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;
}
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);
}
Aggregations