jdk/src/share/classes/javax/swing/table/JTableHeader.java
author malenkov
Wed, 30 Apr 2014 19:28:05 +0400
changeset 24544 c0133e7c7162
parent 22574 7f8ce0c8c20a
child 25172 b345c47c02b3
permissions -rw-r--r--
8041917: unexcepted behavior of LineBorder while using Boolean variable true Reviewed-by: alexsch, serb
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * Returns the the dragged column, if and only if, a drag is in
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
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * @return  the index of the column that <code>point</code> lies in, or -1 if it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     *          lies out of bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    public int columnAtPoint(Point point) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        int x = point.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        if (!getComponentOrientation().isLeftToRight()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            x = getWidthInRightToLeft() - x - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        return getColumnModel().getColumnIndexAtX(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * Returns the rectangle containing the header tile at <code>column</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * When the <code>column</code> parameter is out of bounds this method uses the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * same conventions as the <code>JTable</code> method <code>getCellRect</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * @return  the rectangle containing the header tile at <code>column</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * @see JTable#getCellRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    public Rectangle getHeaderRect(int column) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        Rectangle r = new Rectangle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        TableColumnModel cm = getColumnModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        r.height = getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        if (column < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
            // x = width = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
            if( !getComponentOrientation().isLeftToRight() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                r.x = getWidthInRightToLeft();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        else if (column >= cm.getColumnCount()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            if( getComponentOrientation().isLeftToRight() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                r.x = getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            for(int i = 0; i < column; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                r.x += cm.getColumn(i).getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            if( !getComponentOrientation().isLeftToRight() ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                r.x = getWidthInRightToLeft() - r.x - cm.getColumn(column).getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            r.width = cm.getColumn(column).getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        return r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * Allows the renderer's tips to be used if there is text set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * @param  event  the location of the event identifies the proper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     *                          renderer and, therefore, the proper tip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * @return the tool tip for this component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    public String getToolTipText(MouseEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        String tip = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        Point p = event.getPoint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        int column;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        // Locate the renderer under the event location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        if ((column = columnAtPoint(p)) != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
            TableColumn aColumn = columnModel.getColumn(column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            TableCellRenderer renderer = aColumn.getHeaderRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            if (renderer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                renderer = defaultRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            Component component = renderer.getTableCellRendererComponent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                              getTable(), aColumn.getHeaderValue(), false, false,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                              -1, column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            // Now have to see if the component is a JComponent before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            // getting the tip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            if (component instanceof JComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                // Convert the event to the renderer's coordinate system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                MouseEvent newEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                Rectangle cellRect = getHeaderRect(column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                p.translate(-cellRect.x, -cellRect.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                newEvent = new MouseEvent(component, event.getID(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                                          event.getWhen(), event.getModifiers(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                                          p.x, p.y, event.getXOnScreen(), event.getYOnScreen(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                                          event.getClickCount(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                                          event.isPopupTrigger(), MouseEvent.NOBUTTON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                tip = ((JComponent)component).getToolTipText(newEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        // No tip from the renderer get our own tip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        if (tip == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
            tip = getToolTipText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        return tip;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
// Managing TableHeaderUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    /**
20428
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 5506
diff changeset
   441
     * Returns the look and feel (L&amp;F) object that renders this component.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * @return the <code>TableHeaderUI</code> object that renders this component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    public TableHeaderUI getUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        return (TableHeaderUI)ui;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    /**
20428
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 5506
diff changeset
   450
     * Sets the look and feel (L&amp;F) object that renders this component.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     *
20428
929cd48fca8a 8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents: 5506
diff changeset
   452
     * @param ui  the <code>TableHeaderUI</code> L&amp;F object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    public void setUI(TableHeaderUI ui){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        if (this.ui != ui) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            super.setUI(ui);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * 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
   464
     * (L&amp;F) has changed.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * Replaces the current UI object with the latest version from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * <code>UIManager</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * @see JComponent#updateUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    public void updateUI(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        setUI((TableHeaderUI)UIManager.getUI(this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        TableCellRenderer renderer = getDefaultRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        if (renderer instanceof Component) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            SwingUtilities.updateComponentTreeUI((Component)renderer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * 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
   482
     * (L&amp;F) class used to render this component.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * @return the string "TableHeaderUI"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * @return "TableHeaderUI"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * @see JComponent#getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    public String getUIClassID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        return uiClassID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
// Managing models
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
//
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
     *  Sets the column model for this table to <code>newModel</code> and registers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     *  for listener notifications from the new column model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * @param   columnModel     the new data source for this table
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * @exception IllegalArgumentException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     *                          if <code>newModel</code> is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * @see     #getColumnModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     *  bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     *  description: The object governing the way columns appear in the view.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    public void setColumnModel(TableColumnModel columnModel) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        if (columnModel == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
            throw new IllegalArgumentException("Cannot set a null ColumnModel");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        TableColumnModel old = this.columnModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        if (columnModel != old) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            if (old != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                old.removeColumnModelListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
            this.columnModel = columnModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
            columnModel.addColumnModelListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
            firePropertyChange("columnModel", old, columnModel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
            resizeAndRepaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * Returns the <code>TableColumnModel</code> that contains all column information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * of this table header.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * @return  the <code>columnModel</code> property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * @see     #setColumnModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    public TableColumnModel getColumnModel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        return columnModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
// Implementing TableColumnModelListener interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * Invoked when a column is added to the table column model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * Application code will not use these methods explicitly, they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * are used internally by <code>JTable</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * @param e  the event received
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * @see TableColumnModelListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    public void columnAdded(TableColumnModelEvent e) { resizeAndRepaint(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * Invoked when a column is removed from the table column model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * Application code will not use these methods explicitly, they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * are used internally by <code>JTable</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * @param e  the event received
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * @see TableColumnModelListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
    public void columnRemoved(TableColumnModelEvent e) { resizeAndRepaint(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * Invoked when a column is repositioned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * Application code will not use these methods explicitly, they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * are used internally by <code>JTable</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * @param e the event received
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * @see TableColumnModelListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    public void columnMoved(TableColumnModelEvent e) { repaint(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * Invoked when a column is moved due to a margin change.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     * Application code will not use these methods explicitly, they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * are used internally by <code>JTable</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * @param e the event received
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * @see TableColumnModelListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    public void columnMarginChanged(ChangeEvent e) { resizeAndRepaint(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    // --Redrawing the header is slow in cell selection mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    // --Since header selection is ugly and it is always clear from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    // --view which columns are selected, don't redraw the header.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * Invoked when the selection model of the <code>TableColumnModel</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * is changed.  This method currently has no effect (the header is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * redrawn).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * Application code will not use these methods explicitly, they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * are used internally by <code>JTable</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     * @param e the event received
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * @see TableColumnModelListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
    public void columnSelectionChanged(ListSelectionEvent e) { } // repaint(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
//  Package Methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     *  Returns the default column model object which is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     *  a <code>DefaultTableColumnModel</code>.  A subclass can override this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     *  method to return a different column model object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * @return the default column model object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    protected TableColumnModel createDefaultColumnModel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        return new DefaultTableColumnModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     *  Returns a default renderer to be used when no header renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     *  is defined by a <code>TableColumn</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     *  @return the default table column renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    protected TableCellRenderer createDefaultRenderer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        return new DefaultTableCellHeaderRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     * Initializes the local variables and properties with default values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     * Used by the constructor methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    protected void initializeLocalVars() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        setOpaque(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        table = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        reorderingAllowed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        resizingAllowed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        draggedColumn = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        draggedDistance = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        resizingColumn = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        updateTableInRealTime = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
        // I'm registered to do tool tips so we can draw tips for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        // renderers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
        ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        toolTipManager.registerComponent(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        setDefaultRenderer(createDefaultRenderer());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     * Sizes the header and marks it as needing display.  Equivalent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     * to <code>revalidate</code> followed by <code>repaint</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    public void resizeAndRepaint() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        revalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
      *  Sets the header's <code>draggedColumn</code> to <code>aColumn</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
      *  <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
      *  Application code will not use this method explicitly, it is used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
      *  internally by the column dragging mechanism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
      *  @param  aColumn  the column being dragged, or <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
      *                 no column is being dragged
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    public void setDraggedColumn(TableColumn aColumn) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        draggedColumn = aColumn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
      *  Sets the header's <code>draggedDistance</code> to <code>distance</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
      *  @param distance  the distance dragged
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    public void setDraggedDistance(int distance) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        draggedDistance = distance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
      *  Sets the header's <code>resizingColumn</code> to <code>aColumn</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
      *  <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
      *  Application code will not use this method explicitly, it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
      *  is used internally by the column sizing mechanism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
      *  @param  aColumn  the column being resized, or <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
      *                 no column is being resized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
    public void setResizingColumn(TableColumn aColumn) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        resizingColumn = aColumn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     * See <code>readObject</code> and <code>writeObject</code> in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * <code>JComponent</code> for more
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     * information about serialization in Swing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    private void writeObject(ObjectOutputStream s) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
        s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        if ((ui != null) && (getUIClassID().equals(uiClassID))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
            ui.installUI(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    private int getWidthInRightToLeft() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        if ((table != null) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
            (table.getAutoResizeMode() != JTable.AUTO_RESIZE_OFF)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
            return table.getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        return super.getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * Returns a string representation of this <code>JTableHeader</code>. This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     * is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     * implementations. The returned string may be empty but may not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     * be <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * Overriding <code>paramString</code> to provide information about the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     * specific new aspects of the JFC components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     * @return  a string representation of this <code>JTableHeader</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
        String reorderingAllowedString = (reorderingAllowed ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
                                          "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
        String resizingAllowedString = (resizingAllowed ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
                                        "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        String updateTableInRealTimeString = (updateTableInRealTime ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
                                              "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
        return super.paramString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
        ",draggedDistance=" + draggedDistance +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        ",reorderingAllowed=" + reorderingAllowedString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
        ",resizingAllowed=" + resizingAllowedString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        ",updateTableInRealTime=" + updateTableInRealTimeString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
/////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
// Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
     * Gets the AccessibleContext associated with this JTableHeader.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     * For JTableHeaders, the AccessibleContext takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     * AccessibleJTableHeader.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
     * A new AccessibleJTableHeader instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
     * @return an AccessibleJTableHeader that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
     *         AccessibleContext of this JTableHeader
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
            accessibleContext = new AccessibleJTableHeader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
    // *** should also implement AccessibleSelection?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    // *** and what's up with keyboard navigation/manipulation?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
     * <code>JTableHeader</code> class.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     * Java Accessibility API appropriate to table header user-interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     * elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     * 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
   780
     * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
     */
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 21278
diff changeset
   784
    @SuppressWarnings("serial") // Same-version serialization only
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
    protected class AccessibleJTableHeader extends AccessibleJComponent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
         * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
         * @return an instance of AccessibleRole describing the role of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
         * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
         * @see AccessibleRole
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
            return AccessibleRole.PANEL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
         * Returns the Accessible child, if one exists, contained at the local
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
         * coordinate Point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
         * @param p The point defining the top-left corner of the Accessible,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
         * given in the coordinate space of the object's parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
         * @return the Accessible, if it exists, at the specified location;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
         * else null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
        public Accessible getAccessibleAt(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
            int column;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
            // Locate the renderer under the Point
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
            if ((column = JTableHeader.this.columnAtPoint(p)) != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
                TableColumn aColumn = JTableHeader.this.columnModel.getColumn(column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
                TableCellRenderer renderer = aColumn.getHeaderRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
                if (renderer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
                    if (defaultRenderer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
                        renderer = defaultRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
                Component component = renderer.getTableCellRendererComponent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
                                  JTableHeader.this.getTable(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
                                  aColumn.getHeaderValue(), false, false,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
                                  -1, column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
                return new AccessibleJTableHeaderEntry(column, JTableHeader.this, JTableHeader.this.table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
         * Returns the number of accessible children in the object.  If all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
         * of the children of this object implement Accessible, than this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
         * method should return the number of children of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
         * @return the number of accessible children in the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
        public int getAccessibleChildrenCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
            return JTableHeader.this.columnModel.getColumnCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
         * Return the nth Accessible child of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
         * @param i zero-based index of child
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
         * @return the nth Accessible child of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
        public Accessible getAccessibleChild(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
            if (i < 0 || i >= getAccessibleChildrenCount()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
                TableColumn aColumn = JTableHeader.this.columnModel.getColumn(i)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
                TableCellRenderer renderer = aColumn.getHeaderRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
                if (renderer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
                    if (defaultRenderer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
                        renderer = defaultRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
                Component component = renderer.getTableCellRendererComponent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
                                  JTableHeader.this.getTable(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
                                  aColumn.getHeaderValue(), false, false,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
                                  -1, i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
                return new AccessibleJTableHeaderEntry(i, JTableHeader.this, JTableHeader.this.table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
      /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
       * This class provides an implementation of the Java Accessibility
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20458
diff changeset
   874
       * API appropriate for JTableHeader entries.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
       */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
        protected class AccessibleJTableHeaderEntry extends AccessibleContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
            implements Accessible, AccessibleComponent  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
            private JTableHeader parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
            private int column;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
            private JTable table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
             *  Constructs an AccessiblJTableHeaaderEntry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
             * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
            public AccessibleJTableHeaderEntry(int c, JTableHeader p, JTable t) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
                parent = p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
                column = c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
                table = t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
                this.setAccessibleParent(parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
            /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
             * Get the AccessibleContext associated with this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
             * In the implementation of the Java Accessibility API
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
             * for this class, returns this object, which serves as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
             * its own AccessibleContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
             * @return this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
            public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
                return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
            private AccessibleContext getCurrentAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
                TableColumnModel tcm = table.getColumnModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
                if (tcm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
                    // Fixes 4772355 - ArrayOutOfBoundsException in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
                    // JTableHeader
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
                    if (column < 0 || column >= tcm.getColumnCount()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
                    TableColumn aColumn = tcm.getColumn(column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
                    TableCellRenderer renderer = aColumn.getHeaderRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
                    if (renderer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
                        if (defaultRenderer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
                            renderer = defaultRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
                            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
                    Component c = renderer.getTableCellRendererComponent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
                                      JTableHeader.this.getTable(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
                                      aColumn.getHeaderValue(), false, false,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
                                      -1, column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
                    if (c instanceof Accessible) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
                        return ((Accessible) c).getAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
            private Component getCurrentComponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
                TableColumnModel tcm = table.getColumnModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
                if (tcm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
                    // Fixes 4772355 - ArrayOutOfBoundsException in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
                    // JTableHeader
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
                    if (column < 0 || column >= tcm.getColumnCount()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
                    TableColumn aColumn = tcm.getColumn(column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
                    TableCellRenderer renderer = aColumn.getHeaderRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
                    if (renderer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
                        if (defaultRenderer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
                            renderer = defaultRenderer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
                            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
                    return renderer.getTableCellRendererComponent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
                                      JTableHeader.this.getTable(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
                                      aColumn.getHeaderValue(), false, false,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
                                      -1, column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
        // AccessibleContext methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
            public String getAccessibleName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
                    String name = ac.getAccessibleName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
                    if ((name != null) && (name != "")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
                        // return the cell renderer's AccessibleName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
                        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
                if ((accessibleName != null) && (accessibleName != "")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
                    return accessibleName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
                    // fall back to the client property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
                    String name = (String)getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
                    if (name != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
                        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
                        return table.getColumnName(column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
            public void setAccessibleName(String s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
                    ac.setAccessibleName(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
                    super.setAccessibleName(s);
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
            // *** should check toolTip text for desc. (needs MouseEvent)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
            public String getAccessibleDescription() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
                    return ac.getAccessibleDescription();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
                    return super.getAccessibleDescription();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
            public void setAccessibleDescription(String s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
                    ac.setAccessibleDescription(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
                    super.setAccessibleDescription(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
            public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
                    return ac.getAccessibleRole();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
                    return AccessibleRole.COLUMN_HEADER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
            public AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
                    AccessibleStateSet states = ac.getAccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
                    if (isShowing()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
                        states.add(AccessibleState.SHOWING);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
                    return states;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
                    return new AccessibleStateSet();  // must be non null?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
            public int getAccessibleIndexInParent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
                return column;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
            public int getAccessibleChildrenCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
                    return ac.getAccessibleChildrenCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
                    return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
            public Accessible getAccessibleChild(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
                    Accessible accessibleChild = ac.getAccessibleChild(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
                    ac.setAccessibleParent(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
                    return accessibleChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
            public Locale getLocale() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
                    return ac.getLocale();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
            public void addPropertyChangeListener(PropertyChangeListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
                    ac.addPropertyChangeListener(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
                    super.addPropertyChangeListener(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
            public void removePropertyChangeListener(PropertyChangeListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
                if (ac != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
                    ac.removePropertyChangeListener(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
                    super.removePropertyChangeListener(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
            public AccessibleAction getAccessibleAction() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
                return getCurrentAccessibleContext().getAccessibleAction();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
           /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
            * Get the AccessibleComponent associated with this object.  In the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
            * implementation of the Java Accessibility API for this class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
            * return this object, which is responsible for implementing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
            * AccessibleComponent interface on behalf of itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
            *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
            * @return this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
            */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
            public AccessibleComponent getAccessibleComponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
                return this; // to override getBounds()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
            public AccessibleSelection getAccessibleSelection() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
                return getCurrentAccessibleContext().getAccessibleSelection();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
            public AccessibleText getAccessibleText() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
                return getCurrentAccessibleContext().getAccessibleText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
            public AccessibleValue getAccessibleValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
                return getCurrentAccessibleContext().getAccessibleValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
        // AccessibleComponent methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
            public Color getBackground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
                    return ((AccessibleComponent) ac).getBackground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
                        return c.getBackground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
            public void setBackground(Color c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
                    ((AccessibleComponent) ac).setBackground(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
                    Component cp = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
                    if (cp != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
                        cp.setBackground(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
            public Color getForeground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
                    return ((AccessibleComponent) ac).getForeground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
                        return c.getForeground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
            public void setForeground(Color c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
                    ((AccessibleComponent) ac).setForeground(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
                    Component cp = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
                    if (cp != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
                        cp.setForeground(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
            public Cursor getCursor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
                    return ((AccessibleComponent) ac).getCursor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
                        return c.getCursor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
                        Accessible ap = getAccessibleParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
                        if (ap instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
                            return ((AccessibleComponent) ap).getCursor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
                            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
            public void setCursor(Cursor c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
                    ((AccessibleComponent) ac).setCursor(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
                    Component cp = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
                    if (cp != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
                        cp.setCursor(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
            public Font getFont() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
                    return ((AccessibleComponent) ac).getFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
                        return c.getFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
            public void setFont(Font f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
                    ((AccessibleComponent) ac).setFont(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
                        c.setFont(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
            public FontMetrics getFontMetrics(Font f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
                    return ((AccessibleComponent) ac).getFontMetrics(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
                        return c.getFontMetrics(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
            public boolean isEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
                    return ((AccessibleComponent) ac).isEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
                        return c.isEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
                        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
            public void setEnabled(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
                    ((AccessibleComponent) ac).setEnabled(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
                        c.setEnabled(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
            public boolean isVisible() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
                    return ((AccessibleComponent) ac).isVisible();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
                        return c.isVisible();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
                        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
            public void setVisible(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
                    ((AccessibleComponent) ac).setVisible(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
                        c.setVisible(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
            public boolean isShowing() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
                if (isVisible() && JTableHeader.this.isShowing()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
                    return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
                    return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
            public boolean contains(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
                    Rectangle r = ((AccessibleComponent) ac).getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
                    return r.contains(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
                        Rectangle r = c.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
                        return r.contains(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
                        return getBounds().contains(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
            public Point getLocationOnScreen() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
                if (parent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
                    Point parentLocation = parent.getLocationOnScreen();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
                    Point componentLocation = getLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
                    componentLocation.translate(parentLocation.x, parentLocation.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
                    return componentLocation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
            public Point getLocation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
                    Rectangle r = ((AccessibleComponent) ac).getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
                    return r.getLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
                        Rectangle r = c.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
                        return r.getLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
                        return getBounds().getLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
            public void setLocation(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
//                if ((parent != null)  && (parent.contains(p))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
//                    ensureIndexIsVisible(indexInParent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
//                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
            public Rectangle getBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
                  Rectangle r = table.getCellRect(-1, column, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
                  r.y = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
                  return r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
//                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
//                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
//                    return ((AccessibleComponent) ac).getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
//                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
//                  Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
//                  if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
//                      return c.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
//                  } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
//                      Rectangle r = table.getCellRect(-1, column, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
//                      r.y = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
//                      return r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
//                  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
//              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
            public void setBounds(Rectangle r) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
                    ((AccessibleComponent) ac).setBounds(r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
                        c.setBounds(r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
            public Dimension getSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
                return getBounds().getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
//                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
//                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
//                    Rectangle r = ((AccessibleComponent) ac).getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
//                    return r.getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
//                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
//                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
//                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
//                        Rectangle r = c.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
//                        return r.getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
//                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
//                        return getBounds().getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
//                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
//                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
            public void setSize (Dimension d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
                    ((AccessibleComponent) ac).setSize(d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
                        c.setSize(d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
            public Accessible getAccessibleAt(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
                    return ((AccessibleComponent) ac).getAccessibleAt(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
                    return null;
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
            public boolean isFocusTraversable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
                    return ((AccessibleComponent) ac).isFocusTraversable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
                        return c.isFocusTraversable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
                        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
            public void requestFocus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
                    ((AccessibleComponent) ac).requestFocus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
                        c.requestFocus();
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
            public void addFocusListener(FocusListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
                    ((AccessibleComponent) ac).addFocusListener(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
                        c.addFocusListener(l);
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
            public void removeFocusListener(FocusListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
                AccessibleContext ac = getCurrentAccessibleContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
                if (ac instanceof AccessibleComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
                    ((AccessibleComponent) ac).removeFocusListener(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
                    Component c = getCurrentComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
                    if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
                        c.removeFocusListener(l);
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
        } // inner class AccessibleJTableHeaderElement
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
    }  // inner class AccessibleJTableHeader
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
}  // End of Class JTableHeader