PseudoCodeNode.java 825 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package animation;
  2. import javax.swing.JTree;
  3. import javax.swing.tree.DefaultMutableTreeNode;
  4. import javax.swing.tree.TreePath;
  5. public class PseudoCodeNode extends DefaultMutableTreeNode {
  6. /**
  7. *
  8. */
  9. private static final long serialVersionUID = 1L;
  10. private boolean selected;
  11. private JTree tree;
  12. public PseudoCodeNode( String description, JTree tree )
  13. {
  14. super( description );
  15. selected = false;
  16. this.tree = tree;
  17. }
  18. public boolean isSelected()
  19. {
  20. return selected;
  21. }
  22. public void setSelected( boolean selected )
  23. {
  24. if( selected )
  25. tree.expandPath( new TreePath( this.getPath() ) );
  26. else
  27. tree.collapsePath( new TreePath( this.getPath() ) );
  28. this.selected = selected;
  29. }
  30. }