/[classpath]/classpath/javax/swing/table/JTableHeader.java
ViewVC logotype

Diff of /classpath/javax/swing/table/JTableHeader.java

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

revision 1.4.2.5 by gnu_andrew, Tue Aug 2 20:12:38 2005 UTC revision 1.4.2.6 by gnu_andrew, Wed Nov 2 00:44:02 2005 UTC
# Line 61  import javax.accessibility.AccessibleVal Line 61  import javax.accessibility.AccessibleVal
61  import javax.swing.JComponent;  import javax.swing.JComponent;
62  import javax.swing.JTable;  import javax.swing.JTable;
63  import javax.swing.UIManager;  import javax.swing.UIManager;
64    import javax.swing.event.ChangeEvent;
65    import javax.swing.event.ListSelectionEvent;
66    import javax.swing.event.TableColumnModelEvent;
67    import javax.swing.event.TableColumnModelListener;
68  import javax.swing.plaf.TableHeaderUI;  import javax.swing.plaf.TableHeaderUI;
69    
70  public class JTableHeader extends JComponent  public class JTableHeader extends JComponent
71      implements TableColumnModelListener, Accessible
72  {  {
73    protected class AccessibleJTableHeader extends AccessibleJComponent    protected class AccessibleJTableHeader extends AccessibleJComponent
74    {    {
# Line 305  public class JTableHeader extends JCompo Line 310  public class JTableHeader extends JCompo
310    private static final long serialVersionUID = 5144633983372967710L;    private static final long serialVersionUID = 5144633983372967710L;
311    
312    /**    /**
    * The accessibleContext property.  
    */  
   AccessibleContext accessibleContext;  
   
   /**  
313     * The columnModel property.     * The columnModel property.
314     */     */
315    protected TableColumnModel columnModel;    protected TableColumnModel columnModel;
# Line 373  public class JTableHeader extends JCompo Line 373  public class JTableHeader extends JCompo
373     */     */
374    public JTableHeader(TableColumnModel cm)    public JTableHeader(TableColumnModel cm)
375    {    {
     accessibleContext = new AccessibleJTableHeader();  
376      columnModel = cm == null ? createDefaultColumnModel() : cm;      columnModel = cm == null ? createDefaultColumnModel() : cm;
377      draggedColumn = null;      initializeLocalVars();
     draggedDistance = 0;  
     opaque = true;  
     reorderingAllowed = true;  
     resizingAllowed = true;  
     resizingColumn = null;  
     table = null;  
     updateTableInRealTime = true;  
     cellRenderer = createDefaultRenderer();  
378      updateUI();      updateUI();
379    }    }
380    
# Line 504  public class JTableHeader extends JCompo Line 495  public class JTableHeader extends JCompo
495     */     */
496    public void setColumnModel(TableColumnModel c)    public void setColumnModel(TableColumnModel c)
497    {    {
498        columnModel.removeColumnModelListener(this);
499      columnModel = c;      columnModel = c;
500        columnModel.addColumnModelListener(this);
501    }    }
502    
503    /**    /**
# Line 619  public class JTableHeader extends JCompo Line 612  public class JTableHeader extends JCompo
612    
613    public Rectangle getHeaderRect(int column)    public Rectangle getHeaderRect(int column)
614    {    {
615      Rectangle r = getTable().getCellRect(-1, column, true);      Rectangle r = getTable().getCellRect(-1, column, false);
616      r.height = getHeight();      r.height = getHeight();
617      return r;      return r;
618    }    }
# Line 665  public class JTableHeader extends JCompo Line 658  public class JTableHeader extends JCompo
658            
659      return -1;      return -1;
660    }    }
661    
662      /**
663       * Receives notification when a column is added to the column model.
664       *
665       * @param event the table column model event
666       */
667      public void columnAdded(TableColumnModelEvent event)
668      {
669        // TODO: What else to do here (if anything)?
670        resizeAndRepaint();
671      }
672    
673      /**
674       * Receives notification when a column margin changes in the column model.
675       *
676       * @param event the table column model event
677       */
678      public void columnMarginChanged(ChangeEvent event)
679      {
680        // TODO: What else to do here (if anything)?
681        resizeAndRepaint();
682      }
683    
684      /**
685       * Receives notification when a column is moved within the column model.
686       *
687       * @param event the table column model event
688       */
689      public void columnMoved(TableColumnModelEvent event)
690      {
691        // TODO: What else to do here (if anything)?
692        resizeAndRepaint();
693      }
694    
695      /**
696       * Receives notification when a column is removed from the column model.
697       *
698       * @param event the table column model event
699       */
700      public void columnRemoved(TableColumnModelEvent event)
701      {
702        // TODO: What else to do here (if anything)?
703        resizeAndRepaint();
704      }
705    
706      /**
707       * Receives notification when the column selection has changed.
708       *
709       * @param event the table column model event
710       */
711      public void columnSelectionChanged(ListSelectionEvent event)
712      {
713        // TODO: What else to do here (if anything)?
714        resizeAndRepaint();
715      }
716    
717      /**
718       * Validates the layout of this table header and repaints it. This is
719       * equivalent to <code>revalidate()</code> followed by
720       * <code>repaint()</code>.
721       */
722      public void resizeAndRepaint()
723      {
724        revalidate();
725        repaint();
726      }
727    
728      /**
729       * Initializes the fields and properties of this class with default values.
730       * This is called by the constructors.
731       */
732      protected void initializeLocalVars()
733      {
734        accessibleContext = new AccessibleJTableHeader();
735        draggedColumn = null;
736        draggedDistance = 0;
737        opaque = true;
738        reorderingAllowed = true;
739        resizingAllowed = true;
740        resizingColumn = null;
741        table = null;
742        updateTableInRealTime = true;
743        cellRenderer = createDefaultRenderer();
744      }
745  }  }

Legend:
Removed from v.1.4.2.5  
changed lines
  Added in v.1.4.2.6

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