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

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

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

revision 1.10 by mark, Sat Sep 4 21:14:06 2004 UTC revision 1.11 by mkoch, Sat Sep 25 17:42:16 2004 UTC
# Line 71  public class JTable extends JComponent Line 71  public class JTable extends JComponent
71               ListSelectionListener, CellEditorListener, Accessible               ListSelectionListener, CellEditorListener, Accessible
72  {  {
73    private static final long serialVersionUID = 3876025080382781659L;    private static final long serialVersionUID = 3876025080382781659L;
74      
75    
76    /**    /**
77     * When resizing columns, do not automatically change any columns. In this     * When resizing columns, do not automatically change any columns. In this
# Line 93  public class JTable extends JComponent Line 93  public class JTable extends JComponent
93     * n)</code>, uniformly, to provide or absorb excess space requirements.     * n)</code>, uniformly, to provide or absorb excess space requirements.
94     */     */
95    public static final int AUTO_RESIZE_SUBSEQUENT_COLUMNS = 2;    public static final int AUTO_RESIZE_SUBSEQUENT_COLUMNS = 2;
96      
97    /**    /**
98     * When resizing column <code>i</code> in a table of <code>n</code>     * When resizing column <code>i</code> in a table of <code>n</code>
99     * columns, automatically change all columns in the range <code>[0,     * columns, automatically change all columns in the range <code>[0,
# Line 323  public class JTable extends JComponent Line 323  public class JTable extends JComponent
323     * The tableHeader property.     * The tableHeader property.
324     */     */
325    protected JTableHeader tableHeader;    protected JTableHeader tableHeader;
326      
327        
328    /**    /**
329     * Creates a new <code>JTable</code> instance.     * Creates a new <code>JTable</code> instance.
# Line 433  public class JTable extends JComponent Line 433  public class JTable extends JComponent
433    {    {
434      return new JScrollPane(table);      return new JScrollPane(table);
435    }    }
436    
437    protected TableColumnModel createDefaultColumnModel()    protected TableColumnModel createDefaultColumnModel()
438    {    {
439      return new DefaultTableColumnModel();      return new DefaultTableColumnModel();
# Line 448  public class JTable extends JComponent Line 448  public class JTable extends JComponent
448    {    {
449      return new DefaultListSelectionModel();      return new DefaultListSelectionModel();
450    }    }
451      
452    private void createColumnsFromModel()    private void createColumnsFromModel()
453    {    {
454      if (dataModel == null)      if (dataModel == null)
# Line 457  public class JTable extends JComponent Line 457  public class JTable extends JComponent
457      TableColumnModel cm = createDefaultColumnModel();      TableColumnModel cm = createDefaultColumnModel();
458    
459      for (int i = 0; i < dataModel.getColumnCount(); ++i)      for (int i = 0; i < dataModel.getColumnCount(); ++i)
460    {        {
461          cm.addColumn(new TableColumn(i));          cm.addColumn(new TableColumn(i));
462        }        }
463      this.setColumnModel(cm);      this.setColumnModel(cm);
464    }    }
465      
466    // listener support    // listener support
467    
468    public void columnAdded (TableColumnModelEvent event)    public void columnAdded (TableColumnModelEvent event)
# Line 470  public class JTable extends JComponent Line 470  public class JTable extends JComponent
470      revalidate();      revalidate();
471      repaint();      repaint();
472    }    }
473      
474    public void columnMarginChanged (ChangeEvent event)    public void columnMarginChanged (ChangeEvent event)
475    {    {
476      revalidate();      revalidate();
477      repaint();      repaint();
478    }    }
479    
480    public void columnMoved (TableColumnModelEvent event)    public void columnMoved (TableColumnModelEvent event)
481    {    {
482      revalidate();      revalidate();
# Line 488  public class JTable extends JComponent Line 488  public class JTable extends JComponent
488      revalidate();      revalidate();
489      repaint();      repaint();
490    }    }
491      
492    public void columnSelectionChanged (ListSelectionEvent event)    public void columnSelectionChanged (ListSelectionEvent event)
493    {    {
494      repaint();      repaint();
# Line 508  public class JTable extends JComponent Line 508  public class JTable extends JComponent
508    {    {
509      repaint();      repaint();
510    }    }
511      
512    public void valueChanged (ListSelectionEvent event)    public void valueChanged (ListSelectionEvent event)
513    {    {
514      repaint();      repaint();
515    }    }
516      
517    
518    /**    /**
519     * Calculate the visible rectangle for a particular row and column. The     * Calculate the visible rectangle for a particular row and column. The
# Line 547  public class JTable extends JComponent Line 547  public class JTable extends JComponent
547      int y = (height + y_gap) * row;      int y = (height + y_gap) * row;
548    
549      for (int i = 0; i < column; ++i)      for (int i = 0; i < column; ++i)
550    {        {        
551          x += columnModel.getColumn(i).getWidth();          x += columnModel.getColumn(i).getWidth();
552          x += x_gap;          x += x_gap;
553    }        }
554      
555      if (includeSpacing)      if (includeSpacing)
556        return new Rectangle(x, y, width, height);        return new Rectangle(x, y, width, height);
557      else      else
# Line 580  public class JTable extends JComponent Line 580  public class JTable extends JComponent
580     *     *
581     * @return The current value of the property     * @return The current value of the property
582     */     */
583    public ListSelectionModel getSelectionModel ()    public ListSelectionModel getSelectionModel()
584    {    {
585      if (! rowSelectionAllowed)      if (! rowSelectionAllowed)
586        return null;        return null;
587    
588      return selectionModel;      return selectionModel;
589    }    }
590      
591    public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)    public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
592    {    {
593      if (orientation == SwingConstants.VERTICAL)      if (orientation == SwingConstants.VERTICAL)
# Line 606  public class JTable extends JComponent Line 606  public class JTable extends JComponent
606    {    {
607      return false;      return false;
608    }    }
609      
610    /**    /**
611     * Get the value of the {@link #scrollableTracksViewportWidth} property.     * Get the value of the {@link #scrollableTracksViewportWidth} property.
612     *     *
613     * @return <code>true</code> unless the {@link autoResizeMode} prperty is     * @return <code>true</code> unless the {@link autoResizeMode} prperty is
614     * <code>AUTO_RESIZE_OFF</code>     * <code>AUTO_RESIZE_OFF</code>
615     */     */
616        
617    public boolean getScrollableTracksViewportWidth()    public boolean getScrollableTracksViewportWidth()
618    {    {
619      if (autoResizeMode == AUTO_RESIZE_OFF)      if (autoResizeMode == AUTO_RESIZE_OFF)
# Line 631  public class JTable extends JComponent Line 631  public class JTable extends JComponent
631      if (orientation == SwingConstants.VERTICAL)      if (orientation == SwingConstants.VERTICAL)
632        return rowHeight;        return rowHeight;
633      else      else
634    {        {
635          int sum = 0;          int sum = 0;
636          for (int i = 0; i < getColumnCount(); ++i)          for (int i = 0; i < getColumnCount(); ++i)
637            sum += columnModel.getColumn(0).getWidth();            sum += columnModel.getColumn(0).getWidth();
638          return getColumnCount() == 0 ? 10 : sum / getColumnCount();          return getColumnCount() == 0 ? 10 : sum / getColumnCount();
639    }        }
640    }    }
641    
642    
# Line 646  public class JTable extends JComponent Line 646  public class JTable extends JComponent
646    
647      if (editor == null)      if (editor == null)
648        editor = getDefaultEditor(dataModel.getColumnClass(column));        editor = getDefaultEditor(dataModel.getColumnClass(column));
649        
650      return editor;      return editor;
651    }    }
652    
# Line 655  public class JTable extends JComponent Line 655  public class JTable extends JComponent
655      if (defaultEditorsByColumnClass.containsKey(columnClass))      if (defaultEditorsByColumnClass.containsKey(columnClass))
656        return (TableCellEditor) defaultEditorsByColumnClass.get(columnClass);        return (TableCellEditor) defaultEditorsByColumnClass.get(columnClass);
657      else      else
658    {        {
659          TableCellEditor r = new DefaultCellEditor(new JTextField());          TableCellEditor r = new DefaultCellEditor(new JTextField());
660          defaultEditorsByColumnClass.put(columnClass, r);          defaultEditorsByColumnClass.put(columnClass, r);
661          return r;          return r;
# Line 696  public class JTable extends JComponent Line 696  public class JTable extends JComponent
696      else      else
697        return columnModel.getColumn(vc).getModelIndex();        return columnModel.getColumn(vc).getModelIndex();
698    }    }
699      
700    public int convertColumnIndexToView(int mc)    public int convertColumnIndexToView(int mc)
701    {    {
702      if (mc < 0)      if (mc < 0)
703        return mc;        return mc;
704      int ncols = getColumnCount();      int ncols = getColumnCount();
705      for (int vc = 0; vc < ncols; ++vc)      for (int vc = 0; vc < ncols; ++vc)
706    {        {
707          if (columnModel.getColumn(vc).getModelIndex() == mc)          if (columnModel.getColumn(vc).getModelIndex() == mc)
708            return vc;            return vc;
709        }        }
# Line 729  public class JTable extends JComponent Line 729  public class JTable extends JComponent
729                                                    false, // hasFocus                                                    false, // hasFocus
730                                                    row, column);                                                    row, column);
731    }    }
732      
733    
734    /**    /**
735     * Get the value of the {@link #autoCreateColumnsFromModel} property.     * Get the value of the {@link #autoCreateColumnsFromModel} property.
# Line 790  public class JTable extends JComponent Line 790  public class JTable extends JComponent
790    {    {
791      return getColumnSelectionAllowed() && getRowSelectionAllowed();      return getColumnSelectionAllowed() && getRowSelectionAllowed();
792    }    }
793        
794    /**    /**
795     * Get the value of the {@link #dataModel} property.     * Get the value of the {@link #dataModel} property.
796     *     *
# Line 1540  public class JTable extends JComponent Line 1540  public class JTable extends JComponent
1540      doLayout();      doLayout();
1541    }    }
1542    
   
1543    public String getUIClassID()    public String getUIClassID()
1544    {    {
1545      return "TableUI";      return "TableUI";
1546    }    }
1547    
1548      /**
1549       * This method returns the table's UI delegate.
1550       *
1551       * @return The table's UI delegate.
1552       */
1553    public TableUI getUI()    public TableUI getUI()
1554    {    {
1555      return (TableUI) ui;      return (TableUI) ui;
1556    }    }
1557    
1558      /**
1559       * This method sets the table's UI delegate.
1560       *
1561       * @param ui The table's UI delegate.
1562       */
1563      public void setUI(TableUI ui)
1564      {
1565        super.setUI(ui);
1566      }
1567    
1568    public void updateUI()    public void updateUI()
1569    {    {
1570      setUI((TableUI) UIManager.getUI(this));      setUI((TableUI) UIManager.getUI(this));

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

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