/[classpath]/classpath/javax/swing/JTree.java
ViewVC logotype

Diff of /classpath/javax/swing/JTree.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8.2.9 by gnu_andrew, Tue Aug 16 16:22:38 2005 UTC revision 1.8.2.10 by gnu_andrew, Sat Sep 10 15:31:50 2005 UTC
# Line 339  public class JTree Line 339  public class JTree
339          {          {
340                  setModel(model);                  setModel(model);
341                  setSelectionModel(EmptySelectionModel.sharedInstance());                  setSelectionModel(EmptySelectionModel.sharedInstance());
                 selectionModel.addTreeSelectionListener(selectionRedirector);  
342                  setCellRenderer(new DefaultTreeCellRenderer());                  setCellRenderer(new DefaultTreeCellRenderer());
343                  updateUI();                  updateUI();
344          }          }
# Line 564  public class JTree Line 563  public class JTree
563          }          }
564    
565          /**          /**
566           * Returns the preferred viewport size..           * Returns the preferred viewport size.
567           *           *
568           * @return the preferred size           * @return the preferred size
569           */           */
570          public Dimension getPreferredScrollableViewportSize()          public Dimension getPreferredScrollableViewportSize()
571          {          {
572                  return null;            return new Dimension (getPreferredSize().width, getVisibleRowCount()*getRowHeight());
573          }          }
574    
575          public int getScrollableUnitIncrement(Rectangle visibleRect,          public int getScrollableUnitIncrement(Rectangle visibleRect,
# Line 585  public class JTree Line 584  public class JTree
584                  return 1;                  return 1;
585          }          }
586    
587          public boolean getScrollableTracksViewportWidth()    public boolean getScrollableTracksViewportWidth()
588          {    {
589                  return false;      if (getParent() instanceof JViewport)
590          }        return ((JViewport) getParent()).getHeight() > getPreferredSize().height;
591        return false;
592          public boolean getScrollableTracksViewportHeight()    }
593          {    
594                  return false;    public boolean getScrollableTracksViewportHeight()
595          }    {
596        if (getParent() instanceof JViewport)
597          return ((JViewport) getParent()).getWidth() > getPreferredSize().width;
598        return false;
599      }
600    
601          /**          /**
602           * Adds a <code>TreeExpansionListener</code> object to the tree.           * Adds a <code>TreeExpansionListener</code> object to the tree.
# Line 660  public class JTree Line 663  public class JTree
663           */           */
664          public void addTreeSelectionListener(TreeSelectionListener listener)          public void addTreeSelectionListener(TreeSelectionListener listener)
665          {          {
666                  listenerList.add(TreeSelectionListener.class, listener);        listenerList.add(TreeSelectionListener.class, listener);
667          }          }
668    
669          /**          /**
# Line 692  public class JTree Line 695  public class JTree
695          protected void fireValueChanged(TreeSelectionEvent event)          protected void fireValueChanged(TreeSelectionEvent event)
696          {          {
697                  TreeSelectionListener[] listeners = getTreeSelectionListeners();                  TreeSelectionListener[] listeners = getTreeSelectionListeners();
698    
699                  for (int index = 0; index < listeners.length; ++index)                  for (int index = 0; index < listeners.length; ++index)
700                          listeners[index].valueChanged(event);                          listeners[index].valueChanged(event);
701          }          }
# Line 1277  public class JTree Line 1280  public class JTree
1280          }          }
1281    
1282          public void collapsePath(TreePath path)          public void collapsePath(TreePath path)
1283          {      {
1284                  setExpandedState(path, false);        try
1285          }          {
1286              fireTreeWillCollapse(path);
1287            }
1288          catch (ExpandVetoException ev)
1289            {
1290            }
1291          setExpandedState(path, false);
1292          fireTreeCollapsed(path);
1293        }
1294    
1295          public void collapseRow(int row)          public void collapseRow(int row)
1296          {          {
# Line 1293  public class JTree Line 1304  public class JTree
1304          }          }
1305    
1306          public void expandPath(TreePath path)          public void expandPath(TreePath path)
1307          {      {
1308                  // Don't expand if last path component is a leaf node.        // Don't expand if last path component is a leaf node.
1309                  if ((path == null) || (treeModel.isLeaf(path.getLastPathComponent())))        if ((path == null) || (treeModel.isLeaf(path.getLastPathComponent())))
1310                          return;          return;
1311      
1312                  setExpandedState(path, true);        try
1313          }          {
1314              fireTreeWillExpand(path);
1315            }
1316          catch (ExpandVetoException ev)
1317            {
1318            }
1319      
1320          setExpandedState(path, true);
1321          fireTreeExpanded(path);
1322        }
1323    
1324          public void expandRow(int row)          public void expandRow(int row)
1325          {          {
# Line 1506  public class JTree Line 1526  public class JTree
1526          private void doExpandParents(TreePath path, boolean state)          private void doExpandParents(TreePath path, boolean state)
1527          {          {
1528                  TreePath parent = path.getParentPath();                          TreePath parent = path.getParentPath();        
1529                  if (isExpanded(parent))          
1530                  {                  if (!isExpanded(parent) && parent != null)
                         nodeStates.put(path, state ? EXPANDED : COLLAPSED);  
                         return;  
                 }  
   
                 if (parent != null)  
1531                          doExpandParents(parent, false);                          doExpandParents(parent, false);
1532    
1533                  nodeStates.put(path, state ? EXPANDED : COLLAPSED);                  nodeStates.put(path, state ? EXPANDED : COLLAPSED);
# Line 1522  public class JTree Line 1537  public class JTree
1537          {          {
1538                  if (path == null)                  if (path == null)
1539                          return;                          return;
   
1540                  TreePath parent = path.getParentPath();                  TreePath parent = path.getParentPath();
1541    
1542                  doExpandParents(path, state);                  doExpandParents(path, state);

Legend:
Removed from v.1.8.2.9  
changed lines
  Added in v.1.8.2.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26