X

Geertjan's Blog

  • January 12, 2011

org.openide.explorer.propertysheet.PropertyPanel (Part 2)

Geertjan Wielenga
Product Manager
Some more fun with PropertyPanels (and MigLayout):

Code:

public class BicycleNode extends BeanNode {
private PropertyPanel itemPP;
private TopComponent tc = new TopComponent();
public BicycleNode(BicycleItem item) throws IntrospectionException {
super(item, Children.LEAF, Lookups.singleton(item));
setDisplayName(item.getName());
}
@Override
public Action getPreferredAction() {
return new OpenDetailsAction();
}
public class OpenDetailsAction extends AbstractAction {
@Override
public void actionPerformed(ActionEvent e) {
JPanel panel = new JPanel(new MigLayout());
tc.removeAll();
tc.setDisplayName(getDisplayName());
tc.setLayout(new BorderLayout());
panel.setBorder(new LineBorder(Color.RED, 2));
tc.add(panel, BorderLayout.CENTER);
for (Property property : getPropertySets()[0].getProperties()) {
if (!property.getName().equals("class")) {
itemPP = new PropertyPanel();
itemPP.setProperty(property);
panel.add(new JLabel(property.getName().toUpperCase() + ": "));
panel.add(itemPP, "wrap, gaptop 10");
tc.repaint();
tc.validate();
}
}
tc.open();
tc.requestActive();
}
}
}

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.