jdk/src/java.desktop/share/classes/javax/swing/table/JTableHeader.java
author prr
Tue, 16 Dec 2014 09:58:02 -0800
changeset 28236 610561ed1847
parent 28231 b608ffcaed74
parent 28059 e576535359cc
child 29732 56cf17d42243
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 21278
diff changeset
     2
 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 466
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 466
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 466
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 466
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 466
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.swing.table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import sun.swing.table.DefaultTableCellHeaderRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.swing.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import javax.accessibility.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.beans.PropertyChangeListener;
466
6acd5ec503a8 4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents: 2
diff changeset
    40
import java.beans.Transient;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * This is the object which manages the header of the <code>JTable</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * the same version of Swing.  As of 1.4, support for long term storage
20458
f2423fb3fd19 8025840: Fix all the doclint warnings about trademark
cl
parents: 20428
diff changeset
    55
 * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * @author Alan Chung
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * @author Philip Milne
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * @see javax.swing.JTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 */
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 21278
diff changeset
    63
@SuppressWarnings("serial") // Same-version serialization only
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
public class JTableHeader extends JComponent implements TableColumnModelListener, Accessible
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * @see #getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @see #readObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private static final String uiClassID = "TableHeaderUI";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
// Instance Variables
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * The table for which this object is the header;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * the default is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    protected JTable table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * The <code>TableColumnModel</code> of the table header.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    protected TableColumnModel  columnModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * If true, reordering of columns are allowed by the user;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * the default is true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    protected boolean   reorderingAllowed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * If true, resizing of columns are allowed by the user;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * the default is true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    protected boolean   resizingAllowed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * Obsolete as of Java 2 platform v1.3.  Real time repaints, in response
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * to column dragging or resizing, are now unconditional.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * If this flag is true, then the header will repaint the table as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * a column is dragged or resized; the default is true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    protected boolean   updateTableInRealTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    /** The index of the column being resized. <code>null</code> if not resizing. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    transient protected TableColumn     resizingColumn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    /** The index of the column being dragged. <code>null</code> if not dragging. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    transient protected TableColumn     draggedColumn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /** The distance from its original position the column has been dragged. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    transient protected int     draggedDistance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
      *  The default renderer to be used when a <code>TableColumn</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
      *  does not define a <code>headerRenderer</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    private TableCellRenderer defaultRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
// Constructors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     *  Constructs a <code>JTableHeader</code> with a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *  <code>TableColumnModel</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @see #createDefaultColumnModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    public JTableHeader() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        this(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     *  Constructs a <code>JTableHeader</code> which is initialized with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     *  <code>cm</code> as the column model.  If <code>cm</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     *  <code>null</code> this method will initialize the table header
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     *  with a default <code>TableColumnModel</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * @param cm        the column model for the table
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @see #createDefaultColumnModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    public JTableHeader(TableColumnModel cm) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        //setFocusable(false); // for strict win/mac compatibility mode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                               // this method should be invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        if (cm == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            cm = createDefaultColumnModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        setColumnModel(cm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        // Initialize local ivars
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        initializeLocalVars();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        // Get UI going
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        updateUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
// Local behavior attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     *  Sets the table associated with this header.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     *  @param  table   the new table
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     *  @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     *   bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     *   description: The table associated with this header.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    public void setTable(JTable table) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        JTable old = this.table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        this.table = table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        firePropertyChange("table", old, table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
      *  Returns the table associated with this header.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
      *  @return  the <code>table</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    public JTable getTable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        return table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     *  Sets whether the user can drag column headers to reorder columns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @param   reorderingAllowed       true if the table view should allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *                                  reordering; otherwise false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @see     #getReorderingAllowed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     *  bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     *  description: Whether the user can drag column headers to reorder columns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    public void setReorderingAllowed(boolean reorderingAllowed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        boolean old = this.reorderingAllowed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        this.reorderingAllowed = reorderingAllowed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        firePropertyChange("reorderingAllowed", old, reorderingAllowed);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * Returns true if the user is allowed to rearrange columns by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * dragging their headers, false otherwise. The default is true. You can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * rearrange columns programmatically regardless of this setting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * @return  the <code>reorderingAllowed</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @see     #setReorderingAllowed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    public boolean getReorderingAllowed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        return reorderingAllowed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     *  Sets whether the user can resize columns by dragging between headers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * @param   resizingAllowed         true if table view should allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     *                                  resizing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * @see     #getResizingAllowed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     *  bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     *  description: Whether the user can resize columns by dragging between headers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    public void setResizingAllowed(boolean resizingAllowed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        boolean old = this.resizingAllowed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        this.resizingAllowed = resizingAllowed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        firePropertyChange("resizingAllowed", old, resizingAllowed);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * Returns true if the user is allowed to resize columns by dragging
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * between their headers, false otherwise. The default is true. You can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * resize columns programmatically regardless of this setting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * @return  the <code>resizingAllowed</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * @see     #setResizingAllowed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    public boolean getResizingAllowed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        return resizingAllowed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    /**
28059
e576535359cc 8067377: My hobby: caning, then then canning, the the can-can
martin
parents: 25859
diff changeset
   245
     * Returns the dragged column, if and only if, a drag is in
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * process, otherwise returns <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * @return  the dragged column, if a drag is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     *          process, otherwise returns <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * @see     #getDraggedDistance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    public TableColumn getDraggedColumn() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        return draggedColumn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * Returns the column's horizontal distance from its original
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * position, if and only if, a drag is in process. Otherwise, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * the return value is meaningless.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * @return  the column's horizontal distance from its original
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     *          position, if a drag is in process, otherwise the return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     *          value is meaningless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * @see     #getDraggedColumn
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    public int getDraggedDistance() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        return draggedDistance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * Returns the resizing column.  If no column is being
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * resized this method returns <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * @return  the resizing column, if a resize is in process, otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     *          returns <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    public TableColumn getResizingColumn() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        return resizingColumn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * Obsolete as of Java 2 platform v1.3.  Real time repaints, in response to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * column dragging or resizing, are now unconditional.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     *  Sets whether the body of the table updates in real time when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     *  a column is resized or dragged.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * @param   flag                    true if tableView should update
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     *                                  the body of the table in real time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * @see #getUpdateTableInRealTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    public void setUpdateTableInRealTime(boolean flag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        updateTableInRealTime = flag;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * Obsolete as of Java 2 platform v1.3.  Real time repaints, in response to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * column dragging or resizing, are now unconditional.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * Returns true if the body of the table view updates in real
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * time when a column is resized or dragged.  User can set this flag to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * false to speed up the table's response to user resize or drag actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * The default is true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * @return  true if the table updates in real time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * @see #setUpdateTableInRealTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    public boolean getUpdateTableInRealTime() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        return updateTableInRealTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * Sets the default renderer to be used when no <code>headerRenderer</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * is defined by a <code>TableColumn</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * @param  defaultRenderer  the default renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    public void setDefaultRenderer(TableCellRenderer defaultRenderer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        this.defaultRenderer = defaultRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * Returns the default renderer used when no <code>headerRenderer</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * is defined by a <code>TableColumn</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @return the default renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     */
466
6acd5ec503a8 4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents: 2
diff changeset
   330
    @Transient
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    public TableCellRenderer getDefaultRenderer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        return defaultRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * Returns the index of the column that <code>point</code> lies in, or -1 if it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * lies out of bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     *
25172
b345c47c02b3 8044281: Fix doclint warnings (missing javadoc tags) in javax.swing.table
yan
parents: 22574
diff changeset
   339
     * @param point  if this <code>point</code> lies within a column, the index of
b345c47c02b3 8044281: Fix doclint warnings (missing javadoc tags) in javax.swing.table
yan
parents: 22574
diff changeset
   340
     *               that column will be returned; otherwise it is out of bounds
b345c47c02b3 8044281: Fix doclint warnings (missing javadoc tags) in javax.swing.table
yan
parents: 22574
diff changeset
   341
     *               and -1 is returned
b345c47c02b3 8044281: Fix doclint warnings (missing javadoc tags) in javax.swing.table
yan
parents: 22574
diff changeset
   342
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * @return  the index of the column that <code>point</code> lies in, or -1 if it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     *          lies out of bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    public int columnAtPoint(Point point) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        int x = point.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        if (!getComponentOrientation().isLeftToRight()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            x = getWidthInRightToLeft() - x - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        return getColumnModel().getColumnIndexAtX(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * Returns the rectangle containing the header tile at <code>column</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * When the <code>column</code> parameter is out of bounds this method uses the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * same conventions as the <code>JTable</code> method <code>getCellRect</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     *
25172
b345c47c02b3 8044281: Fix doclint warnings (missing javadoc tags) in javax.swing.table
yan
parents: 22574
diff changeset
   359
     * @param column  index of the column
b345c47c02b3 8044281: Fix doclint warnings (missing javadoc tags) in javax.swing.table
yan
parents: 22574
diff changeset
   360
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * @return  the rectangle containing the header tile at <code>column</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * @see JTable#getCellRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    public Rectangle getHeaderRect(int column) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        Rectangle r = new Rectangle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        TableColumnModel cm = getColumnModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        r.height = getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        if (column < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            // x = width = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
            if( !getComponentOrientation().isLeftToRight() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                r.x = getWidthInRightToLeft();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        else if (column >= cm.getColumnCount()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            if( getComponentOrientation().isLeftToRight() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                r.x = getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            for(int i = 0; i < column; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                r.x += cm.getColumn(i).getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            if( !getComponentOrientation().isLeftToRight() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                r.x = getWidthInRightToLeft() - r.x - cm.getColumn(column).getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
            r.width = cm.getColumn(column).getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        return r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * Allows the renderer's tips to be used if there is text set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * @param  event  the location of the event identifies the proper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     *                          renderer and, therefore, the proper tip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * @return the tool tip for this component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    public String getToolTipText(MouseEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        String tip = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        Point p = event.getPoint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        int column;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        // Locate the renderer under the event location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        if ((column = columnAtPoint(p)) != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            TableColumn aColumn = columnModel.getColumn(column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            TableCellRenderer renderer = aColumn.getHeaderRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
            if (renderer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                renderer = defaultRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            Component component = renderer.getTableCellRendererComponent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                              getTable(), aColumn.getHeaderValue(), false, false,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                              -1, column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            // Now have to see if the component is a JComponent before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            // getting the tip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
            if (component instanceof JComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                // Convert the event to the renderer's coordinate system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                MouseEvent newEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                Rectangle cellRect = getHeaderRect(column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                p.translate(-cellRect.x, -cellRect.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                newEvent = new MouseEvent(component, event.getID(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                                          event.getWhen(), event.getModifiers(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                                          p.x, p.y, event.getXOnScreen(), event.getYOnScreen(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                                          event.getClickCount(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                                          event.isPopupTrigger(), MouseEvent.NOBUTTON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                tip = ((JComponent)component).getToolTipText(newEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        // No tip from the renderer get our own tip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        if (tip == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            tip = getToolTipText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        return tip;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
// Managing TableHeaderUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    /**
20428
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 5506
diff changeset
   447
     * Returns the look and feel (L&amp;F) object that renders this component.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * @return the <code>TableHeaderUI</code> object that renders this component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    public TableHeaderUI getUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        return (TableHeaderUI)ui;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    /**
20428
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 5506
diff changeset
   456
     * Sets the look and feel (L&amp;F) object that renders this component.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     *
20428
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 5506
diff changeset
   458
     * @param ui  the <code>TableHeaderUI</code> L&amp;F object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    public void setUI(TableHeaderUI ui){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        if (this.ui != ui) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            super.setUI(ui);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * Notification from the <code>UIManager</code> that the look and feel
20428
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 5506
diff changeset
   470
     * (L&amp;F) has changed.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * Replaces the current UI object with the latest version from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * <code>UIManager</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * @see JComponent#updateUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    public void updateUI(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        setUI((TableHeaderUI)UIManager.getUI(this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        TableCellRenderer renderer = getDefaultRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        if (renderer instanceof Component) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            SwingUtilities.updateComponentTreeUI((Component)renderer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * Returns the suffix used to construct the name of the look and feel
20428
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 5506
diff changeset
   488
     * (L&amp;F) class used to render this component.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * @return the string "TableHeaderUI"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * @return "TableHeaderUI"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * @see JComponent#getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    public String getUIClassID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        return uiClassID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
// Managing models
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     *  Sets the column model for this table to <code>newModel</code> and registers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     *  for listener notifications from the new column model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * @param   columnModel     the new data source for this table
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * @exception IllegalArgumentException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     *                          if <code>newModel</code> is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * @see     #getColumnModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     *  bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     *  description: The object governing the way columns appear in the view.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    public void setColumnModel(TableColumnModel columnModel) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        if (columnModel == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
            throw new IllegalArgumentException("Cannot set a null ColumnModel");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        TableColumnModel old = this.columnModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        if (columnModel != old) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
            if (old != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                old.removeColumnModelListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
            this.columnModel = columnModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
            columnModel.addColumnModelListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
            firePropertyChange("columnModel", old, columnModel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
            resizeAndRepaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * Returns the <code>TableColumnModel</code> that contains all column information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * of this table header.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * @return  the <code>columnModel</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * @see     #setColumnModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    public TableColumnModel getColumnModel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        return columnModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
// Implementing TableColumnModelListener interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * Invoked when a column is added to the table column model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * Application code will not use these methods explicitly, they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * are used internally by <code>JTable</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * @param e  the event received
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * @see TableColumnModelListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    public void columnAdded(TableColumnModelEvent e) { resizeAndRepaint(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * Invoked when a column is removed from the table column model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * Application code will not use these methods explicitly, they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * are used internally by <code>JTable</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * @param e  the event received
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * @see TableColumnModelListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    public void columnRemoved(TableColumnModelEvent e) { resizeAndRepaint(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * Invoked when a column is repositioned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * Application code will not use these methods explicitly, they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * are used internally by <code>JTable</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * @param e the event received
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * @see TableColumnModelListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    public void columnMoved(TableColumnModelEvent e) { repaint(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * Invoked when a column is moved due to a margin change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * Application code will not use these methods explicitly, they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * are used internally by <code>JTable</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     * @param e the event received
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * @see TableColumnModelListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
    public void columnMarginChanged(ChangeEvent e) { resizeAndRepaint(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    // --Redrawing the header is slow in cell selection mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
    // --Since header selection is ugly and it is always clear from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
    // --view which columns are selected, don't redraw the header.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * Invoked when the selection model of the <code>TableColumnModel</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     * is changed.  This method currently has no effect (the header is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * redrawn).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     * Application code will not use these methods explicitly, they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     * are used internally by <code>JTable</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     * @param e the event received
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * @see TableColumnModelListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    public void columnSelectionChanged(ListSelectionEvent e) { } // repaint(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
//  Package Methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     *  Returns the default column model object which is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     *  a <code>DefaultTableColumnModel</code>.  A subclass can override this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     *  method to return a different column model object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * @return the default column model object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    protected TableColumnModel createDefaultColumnModel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        return new DefaultTableColumnModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     *  Returns a default renderer to be used when no header renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     *  is defined by a <code>TableColumn</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     *  @return the default table column renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    protected TableCellRenderer createDefaultRenderer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        return new DefaultTableCellHeaderRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * Initializes the local variables and properties with default values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * Used by the constructor methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    protected void initializeLocalVars() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        setOpaque(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        table = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        reorderingAllowed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
        resizingAllowed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        draggedColumn = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
        draggedDistance = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        resizingColumn = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        updateTableInRealTime = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        // I'm registered to do tool tips so we can draw tips for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        // renderers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        toolTipManager.registerComponent(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        setDefaultRenderer(createDefaultRenderer());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     * Sizes the header and marks it as needing display.  Equivalent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
     * to <code>revalidate</code> followed by <code>repaint</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    public void resizeAndRepaint() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        revalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
      *  Sets the header's <code>draggedColumn</code> to <code>aColumn</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
      *  <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
      *  Application code will not use this method explicitly, it is used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
      *  internally by the column dragging mechanism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
      *  @param  aColumn  the column being dragged, or <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
      *                 no column is being dragged
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    public void setDraggedColumn(TableColumn aColumn) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        draggedColumn = aColumn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
      *  Sets the header's <code>draggedDistance</code> to <code>distance</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
      *  @param distance  the distance dragged
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
    public void setDraggedDistance(int distance) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
        draggedDistance = distance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
      *  Sets the header's <code>resizingColumn</code> to <code>aColumn</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
      *  <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
      *  Application code will not use this method explicitly, it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
      *  is used internally by the column sizing mechanism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
      *  @param  aColumn  the column being resized, or <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
      *                 no column is being resized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    public void setResizingColumn(TableColumn aColumn) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        resizingColumn = aColumn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * See <code>readObject</code> and <code>writeObject</code> in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     * <code>JComponent</code> for more
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * information about serialization in Swing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
    private void writeObject(ObjectOutputStream s) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
        s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        if ((ui != null) && (getUIClassID().equals(uiClassID))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
            ui.installUI(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    private int getWidthInRightToLeft() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        if ((table != null) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
            (table.getAutoResizeMode() != JTable.AUTO_RESIZE_OFF)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
            return table.getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
        return super.getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * Returns a string representation of this <code>JTableHeader</code>. This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     * is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     * implementations. The returned string may be empty but may not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     * be <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     * Overriding <code>paramString</code> to provide information about the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     * specific new aspects of the JFC components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
     * @return  a string representation of this <code>JTableHeader</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
        String reorderingAllowedString = (reorderingAllowed ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
                                          "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
        String resizingAllowedString = (resizingAllowed ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
                                        "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
        String updateTableInRealTimeString = (updateTableInRealTime ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
                                              "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
        return super.paramString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        ",draggedDistance=" + draggedDistance +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        ",reorderingAllowed=" + reorderingAllowedString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        ",resizingAllowed=" + resizingAllowedString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        ",updateTableInRealTime=" + updateTableInRealTimeString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
/////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
// Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
     * Gets the AccessibleContext associated with this JTableHeader.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
     * For JTableHeaders, the AccessibleContext takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
     * AccessibleJTableHeader.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
     * A new AccessibleJTableHeader instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
     * @return an AccessibleJTableHeader that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
     *         AccessibleContext of this JTableHeader
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
            accessibleContext = new AccessibleJTableHeader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
    // *** should also implement AccessibleSelection?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
    // *** and what's up with keyboard navigation/manipulation?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     * <code>JTableHeader</code> class.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     * Java Accessibility API appropriate to table header user-interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     * elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
     * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
     * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
     * the same version of Swing.  As of 1.4, support for long term storage
20458
f2423fb3fd19 8025840: Fix all the doclint warnings about trademark
cl
parents: 20428
diff changeset
   786
     * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
     * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
     * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     */
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 21278
diff changeset
   790
    @SuppressWarnings("serial") // Same-version serialization only
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
    protected class AccessibleJTableHeader extends AccessibleJComponent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
         * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
         * @return an instance of AccessibleRole describing the role of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
         * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
         * @see AccessibleRole
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
            return AccessibleRole.PANEL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
         * Returns the Accessible child, if one exists, contained at the local
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
         * coordinate Point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
         * @param p The point defining the top-left corner of the Accessible,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
         * given in the coordinate space of the object's parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
         * @return the Accessible, if it exists, at the specified location;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
         * else null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        public Accessible getAccessibleAt(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
            int column;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
            // Locate the renderer under the Point
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
            if ((column = JTableHeader.this.columnAtPoint(p)) != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
                TableColumn aColumn = JTableHeader.this.columnModel.getColumn(column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
                TableCellRenderer renderer = aColumn.getHeaderRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
                if (renderer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
                    if (defaultRenderer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
                        renderer = defaultRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
                Component component = renderer.getTableCellRendererComponent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
                                  JTableHeader.this.getTable(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
                                  aColumn.getHeaderValue(), false, false,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
                                  -1, column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
                return new AccessibleJTableHeaderEntry(column, JTableHeader.this, JTableHeader.this.table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
         * Returns the number of accessible children in the object.  If all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
         * of the children of this object implement Accessible, than this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
         * method should return the number of children of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
         * @return the number of accessible children in the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
        public int getAccessibleChildrenCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
            return JTableHeader.this.columnModel.getColumnCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
         * Return the nth Accessible child of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
         * @param i zero-based index of child
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
         * @return the nth Accessible child of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        public Accessible getAccessibleChild(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
            if (i < 0 || i >= getAccessibleChildrenCount()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
                TableColumn aColumn = JTableHeader.this.columnModel.getColumn(i)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
                TableCellRenderer renderer = aColumn.getHeaderRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
                if (renderer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
                    if (defaultRenderer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
                        renderer = defaultRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
                Component component = renderer.getTableCellRendererComponent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
                                  JTableHeader.this.getTable(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
                                  aColumn.getHeaderValue(), false, false,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
                                  -1, i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
                return new AccessibleJTableHeaderEntry(i, JTableHeader.this, JTableHeader.this.table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
      /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
       * This class provides an implementation of the Java Accessibility
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20458
diff changeset
   880
       * API appropriate for JTableHeader entries.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
       */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
        protected class AccessibleJTableHeaderEntry extends AccessibleContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
            implements Accessible, AccessibleComponent  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
            private JTableHeader parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
            private int column;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
            private JTable table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
             *  Constructs an AccessiblJTableHeaaderEntry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
             * @since 1.4
25172
b345c47c02b3 8044281: Fix doclint warnings (missing javadoc tags) in javax.swing.table
yan
parents: 22574
diff changeset
   892
             *
b345c47c02b3 8044281: Fix doclint warnings (missing javadoc tags) in javax.swing.table
yan
parents: 22574
diff changeset
   893
             * @param c  the column index
b345c47c02b3 8044281: Fix doclint warnings (missing javadoc tags) in javax.swing.table
yan
parents: 22574
diff changeset
   894
             * @param p  the parent <code>JTableHeader</code>
b345c47c02b3 8044281: Fix doclint warnings (missing javadoc tags) in javax.swing.table
yan
parents: 22574
diff changeset
   895
             * @param t  the table <code>JTable</code>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
            public AccessibleJTableHeaderEntry(int c, JTableHeader p, JTable t) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
                parent = p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
                column = c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
                table = t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
                this.setAccessibleParent(parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
             * Get the AccessibleContext associated with this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
             * In the implementation of the Java Accessibility API
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
             * for this class, returns this object, which serves as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
             * its own AccessibleContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
             * @return this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
            public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
                return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
            private AccessibleContext getCurrentAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
                TableColumnModel tcm = table.getColumnModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
                if (tcm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
                    // Fixes 4772355 - ArrayOutOfBoundsException in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
                    // JTableHeader
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
                    if (column < 0 || column >= tcm.getColumnCount()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
                    TableColumn aColumn = tcm.getColumn(column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
                    TableCellRenderer renderer = aColumn.getHeaderRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
                    if (renderer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
                        if (defaultRenderer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
                            renderer = defaultRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
                            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
                    Component c = renderer.getTableCellRendererComponent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
                                      JTableHeader.this.getTable(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
                                      aColumn.getHeaderValue(), false, false,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
                                      -1, column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
                    if (c instanceof Accessible) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
                        return ((Accessible) c).getAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
            private Component getCurrentComponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
                TableColumnModel tcm = table.getColumnModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
                if (tcm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
                    // Fixes 4772355 - ArrayOutOfBoundsException in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
                    // JTableHeader
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
                    if (column < 0 || column >= tcm.getColumnCount()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
                    TableColumn aColumn = tcm.getColumn(column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
                    TableCellRenderer renderer = aColumn.getHeaderRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
                    if (renderer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
                        if (defaultRenderer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
                            renderer = defaultRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
                            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
                    return renderer.getTableCellRendererComponent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
                                      JTableHeader.this.getTable(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
                                      aColumn.getHeaderValue(), false, false,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
                                      -1, column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
        // AccessibleContext methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
            public String getAccessibleName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
                    String name = ac.getAccessibleName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
                    if ((name != null) && (name != "")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
                        // return the cell renderer's AccessibleName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
                        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
                if ((accessibleName != null) && (accessibleName != "")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
                    return accessibleName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
                    // fall back to the client property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
                    String name = (String)getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
                    if (name != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
                        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
                        return table.getColumnName(column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
            public void setAccessibleName(String s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
                    ac.setAccessibleName(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
                    super.setAccessibleName(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
            // *** should check toolTip text for desc. (needs MouseEvent)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
            public String getAccessibleDescription() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
                    return ac.getAccessibleDescription();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
                    return super.getAccessibleDescription();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
            public void setAccessibleDescription(String s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
                    ac.setAccessibleDescription(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
                    super.setAccessibleDescription(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
            public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
                    return ac.getAccessibleRole();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
                    return AccessibleRole.COLUMN_HEADER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
            public AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
                    AccessibleStateSet states = ac.getAccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
                    if (isShowing()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
                        states.add(AccessibleState.SHOWING);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
                    return states;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
                    return new AccessibleStateSet();  // must be non null?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
            public int getAccessibleIndexInParent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
                return column;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
            public int getAccessibleChildrenCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
                    return ac.getAccessibleChildrenCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
                    return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
            public Accessible getAccessibleChild(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
                    Accessible accessibleChild = ac.getAccessibleChild(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
                    ac.setAccessibleParent(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
                    return accessibleChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
            public Locale getLocale() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
                    return ac.getLocale();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
            public void addPropertyChangeListener(PropertyChangeListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
                    ac.addPropertyChangeListener(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
                    super.addPropertyChangeListener(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
            public void removePropertyChangeListener(PropertyChangeListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
                    ac.removePropertyChangeListener(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
                    super.removePropertyChangeListener(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
            public AccessibleAction getAccessibleAction() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
                return getCurrentAccessibleContext().getAccessibleAction();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
           /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
            * Get the AccessibleComponent associated with this object.  In the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
            * implementation of the Java Accessibility API for this class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
            * return this object, which is responsible for implementing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
            * AccessibleComponent interface on behalf of itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
            *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
            * @return this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
            */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
            public AccessibleComponent getAccessibleComponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
                return this; // to override getBounds()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
            public AccessibleSelection getAccessibleSelection() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
                return getCurrentAccessibleContext().getAccessibleSelection();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
            public AccessibleText getAccessibleText() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
                return getCurrentAccessibleContext().getAccessibleText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
            public AccessibleValue getAccessibleValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
                return getCurrentAccessibleContext().getAccessibleValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
        // AccessibleComponent methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
            public Color getBackground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
                    return ((AccessibleComponent) ac).getBackground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
                        return c.getBackground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
            public void setBackground(Color c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
                    ((AccessibleComponent) ac).setBackground(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
                    Component cp = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
                    if (cp != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
                        cp.setBackground(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
            public Color getForeground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
                    return ((AccessibleComponent) ac).getForeground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
                        return c.getForeground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
            public void setForeground(Color c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
                    ((AccessibleComponent) ac).setForeground(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
                    Component cp = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
                    if (cp != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
                        cp.setForeground(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
            public Cursor getCursor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
                    return ((AccessibleComponent) ac).getCursor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
                        return c.getCursor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
                        Accessible ap = getAccessibleParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
                        if (ap instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
                            return ((AccessibleComponent) ap).getCursor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
                            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
            public void setCursor(Cursor c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
                    ((AccessibleComponent) ac).setCursor(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
                    Component cp = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
                    if (cp != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
                        cp.setCursor(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
            public Font getFont() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
                    return ((AccessibleComponent) ac).getFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
                        return c.getFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
            public void setFont(Font f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
                    ((AccessibleComponent) ac).setFont(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
                        c.setFont(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
            public FontMetrics getFontMetrics(Font f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
                    return ((AccessibleComponent) ac).getFontMetrics(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
                        return c.getFontMetrics(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
            public boolean isEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
                    return ((AccessibleComponent) ac).isEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
                        return c.isEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
                        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
            public void setEnabled(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
                    ((AccessibleComponent) ac).setEnabled(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
                        c.setEnabled(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
            public boolean isVisible() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
                    return ((AccessibleComponent) ac).isVisible();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
                        return c.isVisible();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
                        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
            public void setVisible(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
                    ((AccessibleComponent) ac).setVisible(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
                        c.setVisible(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
            public boolean isShowing() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
                if (isVisible() && JTableHeader.this.isShowing()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
                    return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
                    return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
            public boolean contains(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
                    Rectangle r = ((AccessibleComponent) ac).getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
                    return r.contains(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
                        Rectangle r = c.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
                        return r.contains(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
                        return getBounds().contains(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
            public Point getLocationOnScreen() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
                if (parent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
                    Point parentLocation = parent.getLocationOnScreen();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
                    Point componentLocation = getLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
                    componentLocation.translate(parentLocation.x, parentLocation.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
                    return componentLocation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
            public Point getLocation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
                    Rectangle r = ((AccessibleComponent) ac).getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
                    return r.getLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
                        Rectangle r = c.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
                        return r.getLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
                        return getBounds().getLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
            public void setLocation(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
//                if ((parent != null)  && (parent.contains(p))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
//                    ensureIndexIsVisible(indexInParent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
//                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
            public Rectangle getBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
                  Rectangle r = table.getCellRect(-1, column, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
                  r.y = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
                  return r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
//                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
//                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
//                    return ((AccessibleComponent) ac).getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
//                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
//                  Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
//                  if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
//                      return c.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
//                  } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
//                      Rectangle r = table.getCellRect(-1, column, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
//                      r.y = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
//                      return r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
//                  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
//              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
            public void setBounds(Rectangle r) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
                    ((AccessibleComponent) ac).setBounds(r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
                        c.setBounds(r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
            public Dimension getSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
                return getBounds().getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
//                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
//                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
//                    Rectangle r = ((AccessibleComponent) ac).getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
//                    return r.getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
//                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
//                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
//                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
//                        Rectangle r = c.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
//                        return r.getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
//                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
//                        return getBounds().getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
//                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
//                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
            public void setSize (Dimension d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
                    ((AccessibleComponent) ac).setSize(d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
                        c.setSize(d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
            public Accessible getAccessibleAt(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
                    return ((AccessibleComponent) ac).getAccessibleAt(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
28231
b608ffcaed74 8066621: Suppress deprecation warnings in java.desktop module
darcy
parents: 25859
diff changeset
  1430
            @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
            public boolean isFocusTraversable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
                    return ((AccessibleComponent) ac).isFocusTraversable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
                        return c.isFocusTraversable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
                        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
            public void requestFocus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
                    ((AccessibleComponent) ac).requestFocus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
                        c.requestFocus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
            public void addFocusListener(FocusListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
                    ((AccessibleComponent) ac).addFocusListener(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
                        c.addFocusListener(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
            public void removeFocusListener(FocusListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
                    ((AccessibleComponent) ac).removeFocusListener(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
                        c.removeFocusListener(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
        } // inner class AccessibleJTableHeaderElement
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
    }  // inner class AccessibleJTableHeader
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
}  // End of Class JTableHeader