java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.marginallyclever.ro3.apps.nodeselector.NodeSelector<T>
Type Parameters:
T - the type of Node to select
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class NodeSelector<T extends Node> extends JPanel

NodeSelector is a component that allows the user to select a Node. Internally it stores a reference to the selected node.

NodeSelector looks like a button. It displays the name of the selected Node. If no node is selected, it displays "...". When the user clicks on the button, a popup menu appears with a JTree of all available nodes.

When the user selects a node, the button's text is updated to show the name of the selected node. Also, a PropertyChangeEvent is fired. The propertyName will be "subject" and the values will be of type T.

NodeSelector also provides a find button. The find action changes the global selection, which updates any other systems listening to the selection.

See Also:
  • Constructor Details

    • NodeSelector

      public NodeSelector(Class<T> type)
    • NodeSelector

      public NodeSelector(Class<T> type, T subject)
  • Method Details

    • setSubject

      public void setSubject(T subject)
    • getSubject

      public T getSubject()
    • setEditable

      public void setEditable(boolean state)
      Enable or disable the find button.
      Parameters:
      state - true to enable, false to disable
    • getEditable

      public boolean getEditable()
      Get the state of the find button.
      Returns:
      true if enabled, false if disabled