1 7 package javax.swing.plaf.synth; 8 9 import javax.swing.*; 10 import java.util.*; 11 12 52 public class Region { 53 private static final Map uiToRegionMap = new HashMap(); 54 private static final Map lowerCaseNameMap = new HashMap(); 55 56 63 public static final Region ARROW_BUTTON = new Region ("ArrowButton", 64 "ArrowButtonUI"); 65 66 70 public static final Region BUTTON = new Region ("Button", 71 "ButtonUI"); 72 73 77 public static final Region CHECK_BOX = new Region ("CheckBox", 78 "CheckBoxUI"); 79 80 84 public static final Region CHECK_BOX_MENU_ITEM = new Region ( 85 "CheckBoxMenuItem", "CheckBoxMenuItemUI"); 86 87 91 public static final Region COLOR_CHOOSER = new Region ( 92 "ColorChooser", "ColorChooserUI"); 93 94 98 public static final Region COMBO_BOX = new Region ( 99 "ComboBox", "ComboBoxUI"); 100 101 105 public static final Region DESKTOP_PANE = new Region ("DesktopPane", 106 "DesktopPaneUI"); 107 111 public static final Region DESKTOP_ICON = new Region ("DesktopIcon", 112 "DesktopIconUI"); 113 114 118 public static final Region EDITOR_PANE = new Region ("EditorPane", 119 "EditorPaneUI"); 120 121 125 public static final Region FILE_CHOOSER = new Region ("FileChooser", 126 "FileChooserUI"); 127 128 132 public static final Region FORMATTED_TEXT_FIELD = new Region ( 133 "FormattedTextField", "FormattedTextFieldUI"); 134 135 139 public static final Region INTERNAL_FRAME = new Region ("InternalFrame", 140 "InternalFrameUI"); 141 147 public static final Region INTERNAL_FRAME_TITLE_PANE = 148 new Region ("InternalFrameTitlePane", 149 "InternalFrameTitlePaneUI"); 150 151 155 public static final Region LABEL = new Region ("Label", "LabelUI"); 156 157 161 public static final Region LIST = new Region ("List", "ListUI"); 162 163 167 public static final Region MENU = new Region ("Menu", "MenuUI"); 168 169 173 public static final Region MENU_BAR = new Region ("MenuBar", "MenuBarUI"); 174 175 179 public static final Region MENU_ITEM = new Region ("MenuItem","MenuItemUI"); 180 181 185 public static final Region MENU_ITEM_ACCELERATOR = new Region ( 186 "MenuItemAccelerator"); 187 188 192 public static final Region OPTION_PANE = new Region ("OptionPane", 193 "OptionPaneUI"); 194 195 199 public static final Region PANEL = new Region ("Panel", "PanelUI"); 200 201 205 public static final Region PASSWORD_FIELD = new Region ("PasswordField", 206 "PasswordFieldUI"); 207 208 212 public static final Region POPUP_MENU = new Region ("PopupMenu", 213 "PopupMenuUI"); 214 215 219 public static final Region POPUP_MENU_SEPARATOR = new Region ( 220 "PopupMenuSeparator", "PopupMenuSeparatorUI"); 221 222 226 public static final Region PROGRESS_BAR = new Region ("ProgressBar", 227 "ProgressBarUI"); 228 229 233 public static final Region RADIO_BUTTON = new Region ( 234 "RadioButton", "RadioButtonUI"); 235 236 240 public static final Region RADIO_BUTTON_MENU_ITEM = new Region ( 241 "RadioButtonMenuItem", "RadioButtonMenuItemUI"); 242 243 247 public static final Region ROOT_PANE = new Region ("RootPane", 248 "RootPaneUI"); 249 250 254 public static final Region SCROLL_BAR = new Region ("ScrollBar", 255 "ScrollBarUI"); 256 260 public static final Region SCROLL_BAR_TRACK = new Region ("ScrollBarTrack"); 261 267 public static final Region SCROLL_BAR_THUMB = new Region ("ScrollBarThumb"); 268 269 273 public static final Region SCROLL_PANE = new Region ("ScrollPane", 274 "ScrollPaneUI"); 275 276 280 public static final Region SEPARATOR = new Region ("Separator", 281 "SeparatorUI"); 282 283 287 public static final Region SLIDER = new Region ("Slider", "SliderUI"); 288 292 public static final Region SLIDER_TRACK = new Region ("SliderTrack"); 293 298 public static final Region SLIDER_THUMB = new Region ("SliderThumb"); 299 300 304 public static final Region SPINNER = new Region ("Spinner", "SpinnerUI"); 305 306 310 public static final Region SPLIT_PANE = new Region ("SplitPane", 311 "SplitPaneUI"); 312 313 317 public static final Region SPLIT_PANE_DIVIDER = new Region ( 318 "SplitPaneDivider"); 319 320 324 public static final Region TABBED_PANE = new Region ("TabbedPane", 325 "TabbedPaneUI"); 326 330 public static final Region TABBED_PANE_TAB = new Region ("TabbedPaneTab"); 331 335 public static final Region TABBED_PANE_TAB_AREA = 336 new Region ("TabbedPaneTabArea"); 337 341 public static final Region TABBED_PANE_CONTENT = 342 new Region ("TabbedPaneContent"); 343 344 348 public static final Region TABLE = new Region ("Table", "TableUI"); 349 350 354 public static final Region TABLE_HEADER = new Region ("TableHeader", 355 "TableHeaderUI"); 356 360 public static final Region TEXT_AREA = new Region ("TextArea", 361 "TextAreaUI"); 362 363 367 public static final Region TEXT_FIELD = new Region ("TextField", 368 "TextFieldUI"); 369 370 374 public static final Region TEXT_PANE = new Region ("TextPane", 375 "TextPaneUI"); 376 377 381 public static final Region TOGGLE_BUTTON = new Region ("ToggleButton", 382 "ToggleButtonUI"); 383 384 388 public static final Region TOOL_BAR = new Region ("ToolBar", "ToolBarUI"); 389 393 public static final Region TOOL_BAR_CONTENT = new Region ("ToolBarContent"); 394 398 public static final Region TOOL_BAR_DRAG_WINDOW = new Region ( 399 "ToolBarDragWindow", null, false); 400 401 405 public static final Region TOOL_TIP = new Region ("ToolTip", "ToolTipUI"); 406 407 411 public static final Region TOOL_BAR_SEPARATOR = new Region ( 412 "ToolBarSeparator", "ToolBarSeparatorUI"); 413 414 418 public static final Region TREE = new Region ("Tree", "TreeUI"); 419 423 public static final Region TREE_CELL = new Region ("TreeCell"); 424 425 429 public static final Region VIEWPORT = new Region ("Viewport", "ViewportUI"); 430 431 432 private String name; 433 private boolean subregion; 434 435 436 static Region getRegion(JComponent c) { 437 return (Region )uiToRegionMap.get(c.getUIClassID()); 438 } 439 440 static void registerUIs(UIDefaults table) { 441 Iterator uis = uiToRegionMap.keySet().iterator(); 442 443 while (uis.hasNext()) { 444 Object key = uis.next(); 445 446 table.put(key, "javax.swing.plaf.synth.SynthLookAndFeel"); 447 } 448 } 449 450 451 Region(String name) { 452 this(name, null, true); 453 } 454 455 Region(String name, String ui) { 456 this(name, ui, false); 457 } 458 459 470 protected Region(String name, String ui, boolean subregion) { 471 if (name == null) { 472 throw new NullPointerException ("You must specify a non-null name"); 473 } 474 this.name = name; 475 if (ui != null) { 476 uiToRegionMap.put(ui, this); 477 } 478 this.subregion = subregion; 479 } 480 481 489 public boolean isSubregion() { 490 return subregion; 491 } 492 493 498 public String getName() { 499 return name; 500 } 501 502 505 String getLowerCaseName() { 506 synchronized(lowerCaseNameMap) { 507 String lowerCaseName = (String )lowerCaseNameMap.get(this); 508 if (lowerCaseName == null) { 509 lowerCaseName = getName().toLowerCase(); 510 lowerCaseNameMap.put(this, lowerCaseName); 511 } 512 return lowerCaseName; 513 } 514 } 515 516 521 public String toString() { 522 return name; 523 } 524 } 525 | Popular Tags |