1 /* JTableHeader.java --
2 Copyright (C) 2003, 2004 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 void addFocusListener(FocusListener l)
75 throw new Error("not implemented");
78 public void addPropertyChangeListener(PropertyChangeListener l)
80 throw new Error("not implemented");
83 public boolean contains(Point p)
85 throw new Error("not implemented");
88 public AccessibleAction getAccessibleAction()
90 throw new Error("not implemented");
93 public Accessible getAccessibleAt(Point p)
95 throw new Error("not implemented");
98 public Accessible getAccessibleChild(int i)
100 throw new Error("not implemented");
103 public int getAccessibleChildrenCount()
105 throw new Error("not implemented");
108 public AccessibleComponent getAccessibleComponent()
110 throw new Error("not implemented");
113 public AccessibleContext getAccessibleContext()
115 throw new Error("not implemented");
118 public String getAccessibleDescription()
120 throw new Error("not implemented");
123 public int getAccessibleIndexInParent()
125 throw new Error("not implemented");
128 public String getAccessibleName()
130 throw new Error("not implemented");
133 public AccessibleRole getAccessibleRole()
135 throw new Error("not implemented");
138 public AccessibleSelection getAccessibleSelection()
140 throw new Error("not implemented");
143 public AccessibleStateSet getAccessibleStateSet()
145 throw new Error("not implemented");
148 public AccessibleText getAccessibleText()
150 throw new Error("not implemented");
153 public AccessibleValue getAccessibleValue()
155 throw new Error("not implemented");
158 public Color getBackground()
160 throw new Error("not implemented");
163 public Rectangle getBounds()
165 throw new Error("not implemented");
168 public Cursor getCursor()
170 throw new Error("not implemented");
173 public Font getFont()
175 throw new Error("not implemented");
178 public FontMetrics getFontMetrics(Font f)
180 throw new Error("not implemented");
183 public Color getForeground()
185 throw new Error("not implemented");
188 public Locale getLocale()
190 throw new Error("not implemented");
193 public Point getLocation()
195 throw new Error("not implemented");
198 public Point getLocationOnScreen()
200 throw new Error("not implemented");
203 public Dimension getSize()
205 throw new Error("not implemented");
208 public boolean isEnabled()
210 throw new Error("not implemented");
213 public boolean isFocusTraversable()
215 throw new Error("not implemented");
218 public boolean isShowing()
220 throw new Error("not implemented");
223 public boolean isVisible()
225 throw new Error("not implemented");
228 public void removeFocusListener(FocusListener l)
230 throw new Error("not implemented");
233 public void removePropertyChangeListener(PropertyChangeListener l)
235 throw new Error("not implemented");
238 public void requestFocus()
240 throw new Error("not implemented");
243 public void setAccessibleDescription(String s)
245 throw new Error("not implemented");
248 public void setAccessibleName(String s)
250 throw new Error("not implemented");
253 public void setBackground(Color c)
255 throw new Error("not implemented");
258 public void setBounds(Rectangle r)
260 throw new Error("not implemented");
263 public void setCursor(Cursor c)
265 throw new Error("not implemented");
268 public void setEnabled(boolean b)
270 throw new Error("not implemented");
273 public void setFont(Font f)
275 throw new Error("not implemented");
278 public void setForeground(Color c)
280 throw new Error("not implemented");
283 public void setLocation(Point p)
285 throw new Error("not implemented");
288 public void setSize(Dimension d)
290 throw new Error("not implemented");
293 public void setVisible(boolean b)
295 throw new Error("not implemented");
300 private static final long serialVersionUID = 5144633983372967710L;
303 * The accessibleContext property.
305 AccessibleContext accessibleContext;
308 * The columnModel property.
310 protected TableColumnModel columnModel;
313 * The draggedColumn property.
315 protected TableColumn draggedColumn;
318 * The draggedDistance property.
320 protected int draggedDistance;
323 * The opaque property.
328 * The reorderingAllowed property.
330 protected boolean reorderingAllowed;
333 * The resizingAllowed property.
335 protected boolean resizingAllowed = true;
338 * The resizingColumn property.
340 protected TableColumn resizingColumn;
343 * The table property.
345 protected JTable table;
348 * The updateTableInRealTime property.
350 protected boolean updateTableInRealTime;
352 TableCellRenderer cellRenderer;
354 public JTableHeader()
359 public JTableHeader(TableColumnModel cm)
361 accessibleContext = new AccessibleJTableHeader();
362 columnModel = cm == null ? createDefaultColumnModel() : cm;
363 draggedColumn = null;
366 reorderingAllowed = true;
367 resizingAllowed = true;
368 resizingColumn = null;
370 updateTableInRealTime = true;
371 cellRenderer = createDefaultRenderer();
375 protected TableColumnModel createDefaultColumnModel()
377 return new DefaultTableColumnModel();
381 * Get the value of the {@link #accessibleContext} property.
383 * @return The current value of the property
385 public AccessibleContext getAccessibleContext()
387 return accessibleContext;
391 * Get the value of the {@link #columnModel} property.
393 * @return The current value of the property
395 public TableColumnModel getColumnModel()
401 * Get the value of the {@link #draggedColumn} property.
403 * @return The current value of the property
405 public TableColumn getDraggedColumn()
407 return draggedColumn;
411 * Get the value of the {@link #draggedDistance} property.
413 * @return The current value of the property
415 public int getDraggedDistance()
417 return draggedDistance;
421 * Get the value of the {@link #reorderingAllowed} property.
423 * @return The current value of the property
425 public boolean getReorderingAllowed()
427 return reorderingAllowed;
431 * Get the value of the {@link #resizingAllowed} property.
433 * @return The current value of the property
435 public boolean getResizingAllowed()
437 return resizingAllowed;
441 * Get the value of the {@link #resizingColumn} property.
443 * @return The current value of the property
445 public TableColumn getResizingColumn()
447 return resizingColumn;
451 * Get the value of the {@link #table} property.
453 * @return The current value of the property
455 public JTable getTable()
461 * Get the value of the {@link #updateTableInRealTime} property.
463 * @return The current value of the property
465 public boolean getUpdateTableInRealTime()
467 return updateTableInRealTime;
471 * Get the value of the {@link #opaque} property.
473 * @return The current value of the property
475 public boolean isOpaque()
481 * Set the value of the {@link #columnModel} property.
483 * @param c The new value of the property
485 public void setColumnModel(TableColumnModel c)
491 * Set the value of the {@link #draggedColumn} property.
493 * @param d The new value of the property
495 public void setDraggedColumn(TableColumn d)
501 * Set the value of the {@link #draggedDistance} property.
503 * @param d The new value of the property
505 public void setDraggedDistance(int d)
511 * Set the value of the {@link #opaque} property.
513 * @param o The new value of the property
515 public void setOpaque(boolean o)
521 * Set the value of the {@link #reorderingAllowed} property.
523 * @param r The new value of the property
525 public void setReorderingAllowed(boolean r)
527 reorderingAllowed = r;
531 * Set the value of the {@link #resizingAllowed} property.
533 * @param r The new value of the property
535 public void setResizingAllowed(boolean r)
541 * Set the value of the {@link #resizingColumn} property.
543 * @param r The new value of the property
545 public void setResizingColumn(TableColumn r)
551 * Set the value of the {@link #table} property.
553 * @param t The new value of the property
555 public void setTable(JTable t)
561 * Set the value of the {@link #updateTableInRealTime} property.
563 * @param u The new value of the property
565 public void setUpdateTableInRealTime(boolean u)
567 updateTableInRealTime = u;
570 protected TableCellRenderer createDefaultRenderer()
572 return new DefaultTableCellRenderer();
575 public TableCellRenderer getDefaultRenderer()
580 public void setDefaultRenderer(TableCellRenderer cellRenderer)
582 this.cellRenderer = cellRenderer;
585 public Rectangle getHeaderRect(int column)
587 Rectangle r = getTable().getCellRect(-1, column, true);
588 r.height = getHeight();
592 protected String paramString()
594 return "JTableHeader";
599 public String getUIClassID()
601 return "TableHeaderUI";
604 public TableHeaderUI getUI()
606 return (TableHeaderUI) ui;
609 public void setUI(TableHeaderUI u)
614 public void updateUI()
616 setUI((TableHeaderUI) UIManager.getUI(this));