jdk/src/share/classes/javax/swing/JSeparator.java
author malenkov
Wed, 30 Apr 2014 19:28:05 +0400
changeset 24544 c0133e7c7162
parent 23010 6dadb192ad81
child 25201 4adc75e0c4e5
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
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 20458
diff changeset
     2
 * Copyright (c) 1997, 2013, 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: 2
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: 2
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: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.accessibility.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <code>JSeparator</code> provides a general purpose component for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * implementing divider lines - most commonly used as a divider
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * between menu items that breaks them up into logical groupings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * Instead of using <code>JSeparator</code> directly,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * you can use the <code>JMenu</code> or <code>JPopupMenu</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <code>addSeparator</code> method to create and add a separator.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <code>JSeparator</code>s may also be used elsewhere in a GUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * wherever a visual divider is useful.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * For more information and examples see
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <a
20455
f6f9a0c2796b 8020688: Broken links in documentation at http://docs.oracle.com/javase/6/docs/api/index.
mcherkas
parents: 20157
diff changeset
    50
 href="http://docs.oracle.com/javase/tutorial/uiswing/components/menu.html">How to Use Menus</a>,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * a section in <em>The Java Tutorial.</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * <strong>Warning:</strong> Swing is not thread safe. For more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * information see <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * href="package-summary.html#threading">Swing's Threading
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * Policy</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * 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: 20455
diff changeset
    63
 * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *      attribute: isContainer false
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *    description: A divider between menu items.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * @author Georges Saab
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * @author Jeff Shapiro
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 */
11268
f0e59c4852de 7116950: Reduce number of warnings in swing
alexsch
parents: 5506
diff changeset
    74
@SuppressWarnings("serial")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
public class JSeparator extends JComponent implements SwingConstants, Accessible
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * @see #getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * @see #readObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    private static final String uiClassID = "SeparatorUI";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    private int orientation = HORIZONTAL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    /** Creates a new horizontal separator. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public JSeparator()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        this( HORIZONTAL );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * Creates a new separator with the specified horizontal or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * vertical orientation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @param orientation an integer specifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     *          <code>SwingConstants.HORIZONTAL</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     *          <code>SwingConstants.VERTICAL</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @exception IllegalArgumentException if <code>orientation</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *          is neither <code>SwingConstants.HORIZONTAL</code> nor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     *          <code>SwingConstants.VERTICAL</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    public JSeparator( int orientation )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        checkOrientation( orientation );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        this.orientation = orientation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        setFocusable(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        updateUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /**
20157
cafca01a8e28 8025230: [cleanup] some more javadoc formatting fixes for swing
yan
parents: 11268
diff changeset
   111
     * Returns the L&amp;F object that renders this component.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @return the SeparatorUI object that renders this component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public SeparatorUI getUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        return (SeparatorUI)ui;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    /**
20157
cafca01a8e28 8025230: [cleanup] some more javadoc formatting fixes for swing
yan
parents: 11268
diff changeset
   120
     * Sets the L&amp;F object that renders this component.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     *
20157
cafca01a8e28 8025230: [cleanup] some more javadoc formatting fixes for swing
yan
parents: 11268
diff changeset
   122
     * @param ui  the SeparatorUI L&amp;F object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *        bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     *       hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *    attribute: visualUpdate true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     *  description: The UI object that implements the Component's LookAndFeel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    public void setUI(SeparatorUI ui) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        super.setUI(ui);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * Resets the UI property to a value from the current look and feel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * @see JComponent#updateUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    public void updateUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        setUI((SeparatorUI)UIManager.getUI(this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /**
20157
cafca01a8e28 8025230: [cleanup] some more javadoc formatting fixes for swing
yan
parents: 11268
diff changeset
   145
     * Returns the name of the L&amp;F class that renders this component.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @return the string "SeparatorUI"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @see JComponent#getUIClassID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @see UIDefaults#getUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    public String getUIClassID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        return uiClassID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * See <code>readObject</code> and <code>writeObject</code> in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * <code>JComponent</code> for more
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * information about serialization in Swing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    private void writeObject(ObjectOutputStream s) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        if (getUIClassID().equals(uiClassID)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            byte count = JComponent.getWriteObjCounter(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            JComponent.setWriteObjCounter(this, --count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            if (count == 0 && ui != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                ui.installUI(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * Returns the orientation of this separator.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @return   The value of the orientation property, one of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     *           following constants defined in <code>SwingConstants</code>:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     *           <code>VERTICAL</code>, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     *           <code>HORIZONTAL</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * @see SwingConstants
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * @see #setOrientation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    public int getOrientation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        return this.orientation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * Sets the orientation of the separator.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * The default value of this property is HORIZONTAL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @param orientation  either <code>SwingConstants.HORIZONTAL</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *                  or <code>SwingConstants.VERTICAL</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @exception IllegalArgumentException  if <code>orientation</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     *          is neither <code>SwingConstants.HORIZONTAL</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *          nor <code>SwingConstants.VERTICAL</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * @see SwingConstants
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * @see #getOrientation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     *        bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     *    preferred: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     *         enum: HORIZONTAL SwingConstants.HORIZONTAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     *               VERTICAL   SwingConstants.VERTICAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *    attribute: visualUpdate true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     *  description: The orientation of the separator.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    public void setOrientation( int orientation ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        if (this.orientation == orientation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        int oldValue = this.orientation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        checkOrientation( orientation );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        this.orientation = orientation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        firePropertyChange("orientation", oldValue, orientation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        revalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    private void checkOrientation( int orientation )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        switch ( orientation )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            case VERTICAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            case HORIZONTAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                throw new IllegalArgumentException( "orientation must be one of: VERTICAL, HORIZONTAL" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * Returns a string representation of this <code>JSeparator</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * implementations. The returned string may be empty but may not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * be <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * @return  a string representation of this <code>JSeparator</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        String orientationString = (orientation == HORIZONTAL ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                                    "HORIZONTAL" : "VERTICAL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        return super.paramString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        ",orientation=" + orientationString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
/////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
// Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * Gets the AccessibleContext associated with this JSeparator.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * For separators, the AccessibleContext takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * AccessibleJSeparator.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * A new AccessibleJSeparator instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * @return an AccessibleJSeparator that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     *         AccessibleContext of this JSeparator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            accessibleContext = new AccessibleJSeparator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * <code>JSeparator</code> class.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * Java Accessibility API appropriate to separator user-interface elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * 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: 20455
diff changeset
   279
     * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     */
11268
f0e59c4852de 7116950: Reduce number of warnings in swing
alexsch
parents: 5506
diff changeset
   283
    @SuppressWarnings("serial")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    protected class AccessibleJSeparator extends AccessibleJComponent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
         * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
         * @return an instance of AccessibleRole describing the role of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
         * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            return AccessibleRole.SEPARATOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
}