1 /* JTableHeader.java --
2 Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax
.swing
.table
;
41 import java
.awt
.Color
;
42 import java
.awt
.Cursor
;
43 import java
.awt
.Dimension
;
45 import java
.awt
.FontMetrics
;
46 import java
.awt
.Point
;
47 import java
.awt
.Rectangle
;
48 import java
.awt
.event
.FocusListener
;
49 import java
.beans
.PropertyChangeListener
;
50 import java
.util
.Locale
;
52 import javax
.accessibility
.Accessible
;
53 import javax
.accessibility
.AccessibleAction
;
54 import javax
.accessibility
.AccessibleComponent
;
55 import javax
.accessibility
.AccessibleContext
;
56 import javax
.accessibility
.AccessibleRole
;
57 import javax
.accessibility
.AccessibleSelection
;
58 import javax
.accessibility
.AccessibleStateSet
;
59 import javax
.accessibility
.AccessibleText
;
60 import javax
.accessibility
.AccessibleValue
;
61 import javax
.swing
.JComponent
;
62 import javax
.swing
.JTable
;
63 import javax
.swing
.UIManager
;
64 import javax
.swing
.plaf
.TableHeaderUI
;
66 public class JTableHeader
extends JComponent
68 protected class AccessibleJTableHeader
extends AccessibleJComponent
70 protected class AccessibleJTableHeaderEntry
extends AccessibleContext
71 implements Accessible
, AccessibleComponent
73 public AccessibleJTableHeaderEntry(int c
, JTableHeader p
, JTable t
)
75 throw new Error("not implemented");
78 public void addFocusListener(FocusListener l
)
80 throw new Error("not implemented");
83 public void addPropertyChangeListener(PropertyChangeListener l
)
85 throw new Error("not implemented");
88 public boolean contains(Point p
)
90 throw new Error("not implemented");
93 public AccessibleAction
getAccessibleAction()
95 throw new Error("not implemented");
98 public Accessible
getAccessibleAt(Point p
)
100 throw new Error("not implemented");
103 public Accessible
getAccessibleChild(int i
)
105 throw new Error("not implemented");
108 public int getAccessibleChildrenCount()
110 throw new Error("not implemented");
113 public AccessibleComponent
getAccessibleComponent()
115 throw new Error("not implemented");
118 public AccessibleContext
getAccessibleContext()
120 throw new Error("not implemented");
123 public String
getAccessibleDescription()
125 throw new Error("not implemented");
128 public int getAccessibleIndexInParent()
130 throw new Error("not implemented");
133 public String
getAccessibleName()
135 throw new Error("not implemented");
138 public AccessibleRole
getAccessibleRole()
140 throw new Error("not implemented");
143 public AccessibleSelection
getAccessibleSelection()
145 throw new Error("not implemented");
148 public AccessibleStateSet
getAccessibleStateSet()
150 throw new Error("not implemented");
153 public AccessibleText
getAccessibleText()
155 throw new Error("not implemented");
158 public AccessibleValue
getAccessibleValue()
160 throw new Error("not implemented");
163 public Color
getBackground()
165 throw new Error("not implemented");
168 public Rectangle
getBounds()
170 throw new Error("not implemented");
173 public Cursor
getCursor()
175 throw new Error("not implemented");
178 public Font
getFont()
180 throw new Error("not implemented");
183 public FontMetrics
getFontMetrics(Font f
)
185 throw new Error("not implemented");
188 public Color
getForeground()
190 throw new Error("not implemented");
193 public Locale
getLocale()
195 throw new Error("not implemented");
198 public Point
getLocation()
200 throw new Error("not implemented");
203 public Point
getLocationOnScreen()
205 throw new Error("not implemented");
208 public Dimension
getSize()
210 throw new Error("not implemented");
213 public boolean isEnabled()
215 throw new Error("not implemented");
218 public boolean isFocusTraversable()
220 throw new Error("not implemented");
223 public boolean isShowing()
225 throw new Error("not implemented");
228 public boolean isVisible()
230 throw new Error("not implemented");
233 public void removeFocusListener(FocusListener l
)
235 throw new Error("not implemented");
238 public void removePropertyChangeListener(PropertyChangeListener l
)
240 throw new Error("not implemented");
243 public void requestFocus()
245 throw new Error("not implemented");
248 public void setAccessibleDescription(String s
)
250 throw new Error("not implemented");
253 public void setAccessibleName(String s
)
255 throw new Error("not implemented");
258 public void setBackground(Color c
)
260 throw new Error("not implemented");
263 public void setBounds(Rectangle r
)
265 throw new Error("not implemented");
268 public void setCursor(Cursor c
)
270 throw new Error("not implemented");
273 public void setEnabled(boolean b
)
275 throw new Error("not implemented");
278 public void setFont(Font f
)
280 throw new Error("not implemented");
283 public void setForeground(Color c
)
285 throw new Error("not implemented");
288 public void setLocation(Point p
)
290 throw new Error("not implemented");
293 public void setSize(Dimension d
)
295 throw new Error("not implemented");
298 public void setVisible(boolean b
)
300 throw new Error("not implemented");
305 private static final long serialVersionUID
= 5144633983372967710L;
308 * The accessibleContext property.
310 AccessibleContext accessibleContext
;
313 * The columnModel property.
315 protected TableColumnModel columnModel
;
318 * The draggedColumn property.
320 protected TableColumn draggedColumn
;
323 * The draggedDistance property.
325 protected int draggedDistance
;
328 * The opaque property.
333 * The reorderingAllowed property.
335 protected boolean reorderingAllowed
;
338 * The resizingAllowed property.
340 protected boolean resizingAllowed
= true;
343 * The resizingColumn property.
345 protected TableColumn resizingColumn
;
348 * The table property.
350 protected JTable table
;
353 * The updateTableInRealTime property.
355 protected boolean updateTableInRealTime
;
357 TableCellRenderer cellRenderer
;
359 public JTableHeader()
364 public JTableHeader(TableColumnModel cm
)
366 accessibleContext
= new AccessibleJTableHeader();
367 columnModel
= cm
== null ?
createDefaultColumnModel() : cm
;
368 draggedColumn
= null;
371 reorderingAllowed
= true;
372 resizingAllowed
= true;
373 resizingColumn
= null;
375 updateTableInRealTime
= true;
376 cellRenderer
= createDefaultRenderer();
380 protected TableColumnModel
createDefaultColumnModel()
382 return new DefaultTableColumnModel();
386 * Get the value of the {@link #accessibleContext} property.
388 * @return The current value of the property
390 public AccessibleContext
getAccessibleContext()
392 return accessibleContext
;
396 * Get the value of the {@link #columnModel} property.
398 * @return The current value of the property
400 public TableColumnModel
getColumnModel()
406 * Get the value of the {@link #draggedColumn} property.
408 * @return The current value of the property
410 public TableColumn
getDraggedColumn()
412 return draggedColumn
;
416 * Get the value of the {@link #draggedDistance} property.
418 * @return The current value of the property
420 public int getDraggedDistance()
422 return draggedDistance
;
426 * Get the value of the {@link #reorderingAllowed} property.
428 * @return The current value of the property
430 public boolean getReorderingAllowed()
432 return reorderingAllowed
;
436 * Get the value of the {@link #resizingAllowed} property.
438 * @return The current value of the property
440 public boolean getResizingAllowed()
442 return resizingAllowed
;
446 * Get the value of the {@link #resizingColumn} property.
448 * @return The current value of the property
450 public TableColumn
getResizingColumn()
452 return resizingColumn
;
456 * Get the value of the {@link #table} property.
458 * @return The current value of the property
460 public JTable
getTable()
466 * Get the value of the {@link #updateTableInRealTime} property.
468 * @return The current value of the property
470 public boolean getUpdateTableInRealTime()
472 return updateTableInRealTime
;
476 * Get the value of the {@link #opaque} property.
478 * @return The current value of the property
480 public boolean isOpaque()
486 * Set the value of the {@link #columnModel} property.
488 * @param c The new value of the property
490 public void setColumnModel(TableColumnModel c
)
496 * Set the value of the {@link #draggedColumn} property.
498 * @param d The new value of the property
500 public void setDraggedColumn(TableColumn d
)
506 * Set the value of the {@link #draggedDistance} property.
508 * @param d The new value of the property
510 public void setDraggedDistance(int d
)
516 * Set the value of the {@link #opaque} property.
518 * @param o The new value of the property
520 public void setOpaque(boolean o
)
526 * Set the value of the {@link #reorderingAllowed} property.
528 * @param r The new value of the property
530 public void setReorderingAllowed(boolean r
)
532 reorderingAllowed
= r
;
536 * Set the value of the {@link #resizingAllowed} property.
538 * @param r The new value of the property
540 public void setResizingAllowed(boolean r
)
546 * Set the value of the {@link #resizingColumn} property.
548 * @param r The new value of the property
550 public void setResizingColumn(TableColumn r
)
556 * Set the value of the {@link #table} property.
558 * @param t The new value of the property
560 public void setTable(JTable t
)
566 * Set the value of the {@link #updateTableInRealTime} property.
568 * @param u The new value of the property
570 public void setUpdateTableInRealTime(boolean u
)
572 updateTableInRealTime
= u
;
575 protected TableCellRenderer
createDefaultRenderer()
577 return new DefaultTableCellRenderer();
580 public TableCellRenderer
getDefaultRenderer()
585 public void setDefaultRenderer(TableCellRenderer cellRenderer
)
587 this.cellRenderer
= cellRenderer
;
590 public Rectangle
getHeaderRect(int column
)
592 Rectangle r
= getTable().getCellRect(-1, column
, true);
593 r
.height
= getHeight();
597 protected String
paramString()
599 return "JTableHeader";
604 public String
getUIClassID()
606 return "TableHeaderUI";
609 public TableHeaderUI
getUI()
611 return (TableHeaderUI
) ui
;
614 public void setUI(TableHeaderUI u
)
619 public void updateUI()
621 setUI((TableHeaderUI
) UIManager
.getUI(this));
624 public int columnAtPoint(Point point
)
626 if (getBounds().contains(point
))
627 return columnModel
.getColumnIndexAtX(point
.x
);