API Overview API Index Package Overview Direct link to this page
JDK 1.6
  javax.swing.plaf.synth. Region View Javadoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524

/*
 * @(#)Region.java	1.31 05/11/17
 *
 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package javax.swing.plaf.synth;

import javax.swing.*;
import java.util.*;

/**
 * A distinct rendering area of a Swing component.  A component may
 * support one or more regions.  Specific component regions are defined
 * by the typesafe enumeration in this class.
 * <p>
 * Regions are typically used as a way to identify the <code>Component</code>s
 * and areas a particular style is to apply to. Synth's file format allows you 
 * to bind styles based on the name of a <code>Region</code>.  
 * The name is derived from the field name of the constant:
 * <ol>
 *  <li>Map all characters to lowercase.
 *  <li>Map the first character to uppercase.
 *  <li>Map the first character after underscores to uppercase.
 *  <li>Remove all underscores.
 * </ol>
 * For example, to identify the <code>SPLIT_PANE</code>
 * <code>Region</code> you would use <code>SplitPane</code>.
 * The following shows a custom <code>SynthStyleFactory</code> 
 * that returns a specific style for split panes:
 * <pre>
 *    public SynthStyle getStyle(JComponent c, Region id) {
 *        if (id == Region.SPLIT_PANE) {
 *            return splitPaneStyle;
 *        }
 *        ...
 *    }
 * </pre>
 * The following <a href="doc-files/synthFileFormat.html">xml</a>
 * accomplishes the same thing:
 * <pre>
 * &lt;style id="splitPaneStyle">
 *   ...
 * &lt;/style>
 * &lt;bind style="splitPaneStyle" type="region" key="SplitPane"/>
 * </pre>
 *
 * @version 1.31, 11/17/05
 * @since 1.5
 * @author Scott Violet
 */
public class Region {
    private static final Map uiToRegionMap = new HashMap();
    private static final Map lowerCaseNameMap = new HashMap();

    /**
     * ArrowButton's are special types of buttons that also render a
     * directional indicator, typically an arrow. ArrowButtons are used by 
     * composite components, for example ScrollBar's contain ArrowButtons.
     * To bind a style to this <code>Region</code> use the name 
     * <code>ArrowButton</code>.
     */
    public static final Region ARROW_BUTTON = new Region("ArrowButton",
                                                         "ArrowButtonUI");

    /**
     * Button region. To bind a style to this <code>Region</code> use the name 
     * <code>Button</code>.
     */
    public static final Region BUTTON = new Region("Button",
                                                   "ButtonUI");

    /**
     * CheckBox region. To bind a style to this <code>Region</code> use the name 
     * <code>CheckBox</code>. 
     */
    public static final Region CHECK_BOX = new Region("CheckBox",
                                                   "CheckBoxUI");

    /**
     * CheckBoxMenuItem region. To bind a style to this <code>Region</code> use 
     * the name <code>CheckBoxMenuItem</code>.
     */
    public static final Region CHECK_BOX_MENU_ITEM = new Region(
                                     "CheckBoxMenuItem", "CheckBoxMenuItemUI");

    /**
     * ColorChooser region. To bind a style to this <code>Region</code> use 
     * the name <code>ColorChooser</code>.
     */
    public static final Region COLOR_CHOOSER = new Region(
                                     "ColorChooser", "ColorChooserUI");

    /**
     * ComboBox region. To bind a style to this <code>Region</code> use 
     * the name <code>ComboBox</code>.
     */
    public static final Region COMBO_BOX = new Region(
                                     "ComboBox", "ComboBoxUI");

    /**
     * DesktopPane region. To bind a style to this <code>Region</code> use 
     * the name <code>DesktopPane</code>.
     */
    public static final Region DESKTOP_PANE = new Region("DesktopPane",
                                                         "DesktopPaneUI");
    /**
     * DesktopIcon region. To bind a style to this <code>Region</code> use 
     * the name <code>DesktopIcon</code>.
     */
    public static final Region DESKTOP_ICON = new Region("DesktopIcon",
                                                         "DesktopIconUI");

    /**
     * EditorPane region. To bind a style to this <code>Region</code> use 
     * the name <code>EditorPane</code>.
     */
    public static final Region EDITOR_PANE = new Region("EditorPane",
                                                        "EditorPaneUI");

    /**
     * FileChooser region. To bind a style to this <code>Region</code> use 
     * the name <code>FileChooser</code>.
     */
    public static final Region FILE_CHOOSER = new Region("FileChooser",
                                                         "FileChooserUI");

    /**
     * FormattedTextField region. To bind a style to this <code>Region</code> use 
     * the name <code>FormattedTextField</code>.
     */
    public static final Region FORMATTED_TEXT_FIELD = new Region(
                            "FormattedTextField", "FormattedTextFieldUI");

    /**
     * InternalFrame region. To bind a style to this <code>Region</code> use 
     * the name <code>InternalFrame</code>.
     */
    public static final Region INTERNAL_FRAME = new Region("InternalFrame",
                                                           "InternalFrameUI");
    /**
     * TitlePane of an InternalFrame. The TitlePane typically 
     * shows a menu, title, widgets to manipulate the internal frame. 
     * To bind a style to this <code>Region</code> use the name 
     * <code>InternalFrameTitlePane</code>.
     */
    public static final Region INTERNAL_FRAME_TITLE_PANE =
                         new Region("InternalFrameTitlePane",
                                    "InternalFrameTitlePaneUI");

    /**
     * Label region. To bind a style to this <code>Region</code> use the name 
     * <code>Label</code>.
     */
    public static final Region LABEL = new Region("Label", "LabelUI");

    /**
     * List region. To bind a style to this <code>Region</code> use the name 
     * <code>List</code>. 
     */
    public static final Region LIST = new Region("List", "ListUI");

    /**
     * Menu region. To bind a style to this <code>Region</code> use the name 
     * <code>Menu</code>.
     */
    public static final Region MENU = new Region("Menu", "MenuUI");

    /**
     * MenuBar region. To bind a style to this <code>Region</code> use the name 
     * <code>MenuBar</code>.
     */
    public static final Region MENU_BAR = new Region("MenuBar", "MenuBarUI");

    /**
     * MenuItem region. To bind a style to this <code>Region</code> use the name 
     * <code>MenuItem</code>.
     */
    public static final Region MENU_ITEM = new Region("MenuItem","MenuItemUI");

    /**
     * Accelerator region of a MenuItem. To bind a style to this 
     * <code>Region</code> use the name <code>MenuItemAccelerator</code>.
     */
    public static final Region MENU_ITEM_ACCELERATOR = new Region(
                                         "MenuItemAccelerator");

    /**
     * OptionPane region. To bind a style to this <code>Region</code> use 
     * the name <code>OptionPane</code>.
     */
    public static final Region OPTION_PANE = new Region("OptionPane",
                                                        "OptionPaneUI");

    /**
     * Panel region. To bind a style to this <code>Region</code> use the name 
     * <code>Panel</code>.
     */
    public static final Region PANEL = new Region("Panel", "PanelUI");

    /**
     * PasswordField region. To bind a style to this <code>Region</code> use 
     * the name <code>PasswordField</code>.
     */
    public static final Region PASSWORD_FIELD = new Region("PasswordField",
                                                           "PasswordFieldUI");

    /**
     * PopupMenu region. To bind a style to this <code>Region</code> use 
     * the name <code>PopupMenu</code>.
     */
    public static final Region POPUP_MENU = new Region("PopupMenu",
                                                       "PopupMenuUI");

    /**
     * PopupMenuSeparator region. To bind a style to this <code>Region</code>
     * use the name <code>PopupMenuSeparator</code>.
     */
    public static final Region POPUP_MENU_SEPARATOR = new Region(
                           "PopupMenuSeparator", "PopupMenuSeparatorUI");

    /**
     * ProgressBar region. To bind a style to this <code>Region</code>
     * use the name <code>ProgressBar</code>.
     */
    public static final Region PROGRESS_BAR = new Region("ProgressBar",
                                                         "ProgressBarUI");

    /**
     * RadioButton region. To bind a style to this <code>Region</code>
     * use the name <code>RadioButton</code>.
     */
    public static final Region RADIO_BUTTON = new Region(
                               "RadioButton", "RadioButtonUI");

    /**
     * RegionButtonMenuItem region. To bind a style to this <code>Region</code>
     * use the name <code>RadioButtonMenuItem</code>.
     */
    public static final Region RADIO_BUTTON_MENU_ITEM = new Region(
                               "RadioButtonMenuItem", "RadioButtonMenuItemUI");

    /**
     * RootPane region. To bind a style to this <code>Region</code> use 
     * the name <code>RootPane</code>.
     */
    public static final Region ROOT_PANE = new Region("RootPane",
                                                      "RootPaneUI");

    /**
     * ScrollBar region. To bind a style to this <code>Region</code> use 
     * the name <code>ScrollBar</code>.
     */
    public static final Region SCROLL_BAR = new Region("ScrollBar",
                                                       "ScrollBarUI");
    /**
     * Track of the ScrollBar. To bind a style to this <code>Region</code> use 
     * the name <code>ScrollBarTrack</code>.
     */
    public static final Region SCROLL_BAR_TRACK = new Region("ScrollBarTrack");
    /**
     * Thumb of the ScrollBar. The thumb is the region of the ScrollBar 
     * that gives a graphical depiction of what percentage of the View is 
     * currently visible. To bind a style to this <code>Region</code> use 
     * the name <code>ScrollBarThumb</code>.
     */
    public static final Region SCROLL_BAR_THUMB = new Region("ScrollBarThumb");

    /**
     * ScrollPane region. To bind a style to this <code>Region</code> use 
     * the name <code>ScrollPane</code>.
     */
    public static final Region SCROLL_PANE = new Region("ScrollPane",
                                                        "ScrollPaneUI");

    /**
     * Separator region. To bind a style to this <code>Region</code> use 
     * the name <code>Separator</code>. 
     */
    public static final Region SEPARATOR = new Region("Separator",
                                                      "SeparatorUI");

    /**
     * Slider region. To bind a style to this <code>Region</code> use 
     * the name <code>Slider</code>.
     */
    public static final Region SLIDER = new Region("Slider", "SliderUI");
    /**
     * Track of the Slider. To bind a style to this <code>Region</code> use 
     * the name <code>SliderTrack</code>.
     */
    public static final Region SLIDER_TRACK = new Region("SliderTrack");
    /**
     * Thumb of the Slider. The thumb of the Slider identifies the current 
     * value. To bind a style to this <code>Region</code> use the name 
     * <code>SliderThumb</code>.
     */
    public static final Region SLIDER_THUMB = new Region("SliderThumb");

    /**
     * Spinner region. To bind a style to this <code>Region</code> use the name
     * <code>Spinner</code>.
     */
    public static final Region SPINNER = new Region("Spinner", "SpinnerUI");

    /**
     * SplitPane region. To bind a style to this <code>Region</code> use the name
     * <code>SplitPane</code>.
     */
    public static final Region SPLIT_PANE = new Region("SplitPane",
                                                      "SplitPaneUI");

    /**
     * Divider of the SplitPane. To bind a style to this <code>Region</code> 
     * use the name <code>SplitPaneDivider</code>.
     */
    public static final Region SPLIT_PANE_DIVIDER = new Region(
                                        "SplitPaneDivider");

    /**
     * TabbedPane region. To bind a style to this <code>Region</code> use 
     * the name <code>TabbedPane</code>.
     */
    public static final Region TABBED_PANE = new Region("TabbedPane",
                                                        "TabbedPaneUI");
    /**
     * Region of a TabbedPane for one tab. To bind a style to this 
     * <code>Region</code> use the name <code>TabbedPaneTab</code>.
     */
    public static final Region TABBED_PANE_TAB = new Region("TabbedPaneTab");
    /**
     * Region of a TabbedPane containing the tabs. To bind a style to this 
     * <code>Region</code> use the name <code>TabbedPaneTabArea</code>.
     */
    public static final Region TABBED_PANE_TAB_AREA =
                                 new Region("TabbedPaneTabArea");
    /**
     * Region of a TabbedPane containing the content. To bind a style to this 
     * <code>Region</code> use the name <code>TabbedPaneContent</code>.
     */
    public static final Region TABBED_PANE_CONTENT =
                                 new Region("TabbedPaneContent");

    /**
     * Table region. To bind a style to this <code>Region</code> use 
     * the name <code>Table</code>.
     */
    public static final Region TABLE = new Region("Table", "TableUI");

    /**
     * TableHeader region. To bind a style to this <code>Region</code> use 
     * the name <code>TableHeader</code>.
     */
    public static final Region TABLE_HEADER = new Region("TableHeader",
                                                         "TableHeaderUI");
    /**
     * TextArea region. To bind a style to this <code>Region</code> use 
     * the name <code>TextArea</code>.
     */
    public static final Region TEXT_AREA = new Region("TextArea",
                                                      "TextAreaUI");

    /**
     * TextField region. To bind a style to this <code>Region</code> use 
     * the name <code>TextField</code>.
     */
    public static final Region TEXT_FIELD = new Region("TextField",
                                                       "TextFieldUI");

    /**
     * TextPane region. To bind a style to this <code>Region</code> use 
     * the name <code>TextPane</code>.
     */
    public static final Region TEXT_PANE = new Region("TextPane",
                                                      "TextPaneUI");

    /**
     * ToggleButton region. To bind a style to this <code>Region</code> use 
     * the name <code>ToggleButton</code>.
     */
    public static final Region TOGGLE_BUTTON = new Region("ToggleButton",
                                                          "ToggleButtonUI");

    /**
     * ToolBar region. To bind a style to this <code>Region</code> use 
     * the name <code>ToolBar</code>.
     */
    public static final Region TOOL_BAR = new Region("ToolBar", "ToolBarUI");
    /**
     * Region of the ToolBar containing the content. To bind a style to this 
     * <code>Region</code> use the name <code>ToolBarContent</code>.
     */
    public static final Region TOOL_BAR_CONTENT = new Region("ToolBarContent");
    /**
     * Region for the Window containing the ToolBar. To bind a style to this 
     * <code>Region</code> use the name <code>ToolBarDragWindow</code>.
     */
    public static final Region TOOL_BAR_DRAG_WINDOW = new Region(
                                        "ToolBarDragWindow", null, false);

    /**
     * ToolTip region. To bind a style to this <code>Region</code> use 
     * the name <code>ToolTip</code>.
     */
    public static final Region TOOL_TIP = new Region("ToolTip", "ToolTipUI");

    /**
     * ToolBar separator region. To bind a style to this <code>Region</code> use 
     * the name <code>ToolBarSeparator</code>.
     */
    public static final Region TOOL_BAR_SEPARATOR = new Region(
                          "ToolBarSeparator", "ToolBarSeparatorUI");

    /**
     * Tree region. To bind a style to this <code>Region</code> use the name 
     * <code>Tree</code>.
     */
    public static final Region TREE = new Region("Tree", "TreeUI");
    /**
     * Region of the Tree for one cell. To bind a style to this 
     * <code>Region</code> use the name <code>TreeCell</code>.
     */
    public static final Region TREE_CELL = new Region("TreeCell");

    /**
     * Viewport region. To bind a style to this <code>Region</code> use 
     * the name <code>Viewport</code>.
     */
    public static final Region VIEWPORT = new Region("Viewport", "ViewportUI");


    private String name;
    private boolean subregion;


    static Region getRegion(JComponent c) {
        return (Region)uiToRegionMap.get(c.getUIClassID());
    }

    static void registerUIs(UIDefaults table) {
        Iterator uis = uiToRegionMap.keySet().iterator();

        while (uis.hasNext()) {
            Object key = uis.next();

            table.put(key, "javax.swing.plaf.synth.SynthLookAndFeel");
        }
    }


    Region(String name) {
        this(name, null, true);
    }

    Region(String name, String ui) {
        this(name, ui, false);
    }

    /**
     * Creates a Region with the specified name. This should only be
     * used if you are creating your own <code>JComponent</code> subclass
     * with a custom <code>ComponentUI</code> class.
     *
     * @param name Name of the region
     * @param ui String that will be returned from
     *           <code>component.getUIClassID</code>. This will be null
     *           if this is a subregion.
     * @param subregion Whether or not this is a subregion.
     */
    protected Region(String name, String ui, boolean subregion) {
        if (name == null) {
            throw new NullPointerException("You must specify a non-null name");
        }
        this.name = name;
        if (ui != null) {
            uiToRegionMap.put(ui, this);
        }
        this.subregion = subregion;
    }

    /**
     * Returns true if the Region is a subregion of a Component, otherwise
     * false. For example, <code>Region.BUTTON</code> corresponds do a
     * <code>Component</code> so that <code>Region.BUTTON.isSubregion()</code>
     * returns false.
     *
     * @return true if the Region is a subregion of a Component.
     */
    public boolean isSubregion() {
        return subregion;
    }

    /**
     * Returns the name of the region.
     *
     * @return name of the Region.
     */
    public String getName() {
        return name;
    }

    /**
     * Returns the name, in lowercase.
     */
    String getLowerCaseName() {
        synchronized(lowerCaseNameMap) {
            String lowerCaseName = (String)lowerCaseNameMap.get(this);
            if (lowerCaseName == null) {
                lowerCaseName = getName().toLowerCase();
                lowerCaseNameMap.put(this, lowerCaseName);
            }
            return lowerCaseName;
        }
    }

    /**
     * Returns the name of the Region.
     *
     * @return name of the Region.
     */
    public String toString() {
        return name;
    }
}

Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar