GNU Classpath (0.17) | ||
Frames | No Frames |
1: /* JSlider.java -- 2: Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 6: GNU Classpath is free software; you can redistribute it and/or modify 7: it under the terms of the GNU General Public License as published by 8: the Free Software Foundation; either version 2, or (at your option) 9: any later version. 10: 11: GNU Classpath is distributed in the hope that it will be useful, but 12: WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14: General Public License for more details. 15: 16: You should have received a copy of the GNU General Public License 17: along with GNU Classpath; see the file COPYING. If not, write to the 18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 21: Linking this library statically or dynamically with other modules is 22: making a combined work based on this library. Thus, the terms and 23: conditions of the GNU General Public License cover the whole 24: combination. 25: 26: As a special exception, the copyright holders of this library give you 27: permission to link this library with independent modules to produce an 28: executable, regardless of the license terms of these independent 29: modules, and to copy and distribute the resulting executable under 30: terms of your choice, provided that you also meet, for each linked 31: independent module, the terms and conditions of the license of that 32: module. An independent module is a module which is not derived from 33: or based on this library. If you modify this library, you may extend 34: this exception to your version of the library, but you are not 35: obligated to do so. If you do not wish to do so, delete this 36: exception statement from your version. */ 37: 38: 39: package javax.swing; 40: 41: import java.awt.Dimension; 42: import java.awt.MenuContainer; 43: import java.awt.image.ImageObserver; 44: import java.io.Serializable; 45: import java.util.Dictionary; 46: import java.util.Enumeration; 47: import java.util.Hashtable; 48: 49: import javax.accessibility.Accessible; 50: import javax.accessibility.AccessibleContext; 51: import javax.accessibility.AccessibleRole; 52: import javax.accessibility.AccessibleStateSet; 53: import javax.accessibility.AccessibleValue; 54: import javax.swing.event.ChangeEvent; 55: import javax.swing.event.ChangeListener; 56: import javax.swing.plaf.SliderUI; 57: 58: /** 59: * The JSlider is a Swing component that allows selection of a value within a 60: * range by adjusting a thumb in a track. The values for the minimum, 61: * maximum, extent and value are stored in a {@link 62: * DefaultBoundedRangeModel}. 63: * 64: * <p> 65: * JSliders have the following properties: 66: * </p> 67: * 68: * <table> 69: * <tr><th> Property </th><th> Stored in </th><th> Bound? </th></tr> 70: * <tr><td> extent </td><td> model </td><td> no </td></tr> 71: * <tr><td> inverted </td><td> slider </td><td> yes </td></tr> 72: * <tr><td> labelTable </td><td> slider </td><td> yes </td></tr> 73: * <tr><td> majorTickSpacing </td><td> slider </td><td> yes </td></tr> 74: * <tr><td> maximum </td><td> model </td><td> no </td></tr> 75: * <tr><td> minimum </td><td> model </td><td> no </td></tr> 76: * <tr><td> minorTickSpacing </td><td> slider </td><td> yes </td></tr> 77: * <tr><td> model </td><td> slider </td><td> yes </td></tr> 78: * <tr><td> orientation </td><td> slider </td><td> yes </td></tr> 79: * <tr><td> paintLabels </td><td> slider </td><td> yes </td></tr> 80: * <tr><td> paintTicks </td><td> slider </td><td> yes </td></tr> 81: * <tr><td> snapToTicks </td><td> slider </td><td> no </td></tr> 82: * <tr><td> value </td><td> model </td><td> no </td></tr> 83: * <tr><td> valueIsAdjusting </td><td> model </td><td> no </td></tr> 84: * </table> 85: * 86: * <p> 87: * The various behavioral aspects of these properties follows: 88: * </p> 89: * 90: * <ul> 91: * <li> 92: * When non-bound properties stored in the slider change, the slider fires 93: * ChangeEvents to its ChangeListeners. 94: * </li> 95: * <li> 96: * When bound properties stored in the slider change, the slider fires 97: * PropertyChangeEvents to its PropertyChangeListeners 98: * </li> 99: * <li> 100: * If any of the model's properties change, it fires a ChangeEvent to its 101: * ChangeListeners, which include the slider. 102: * </li> 103: * <li> 104: * If the slider receives a ChangeEvent from its model, it will propagate the 105: * ChangeEvent to its ChangeListeners, with the ChangeEvent's "source" 106: * property set to refer to the slider, rather than the model. 107: * </li> 108: * </ul> 109: */ 110: public class JSlider extends JComponent implements SwingConstants, Accessible, 111: ImageObserver, 112: MenuContainer, Serializable 113: { 114: /** DOCUMENT ME! */ 115: private static final long serialVersionUID = -1441275936141218479L; 116: 117: /** 118: * DOCUMENT ME! 119: */ 120: protected class AccessibleJSlider extends JComponent.AccessibleJComponent 121: implements AccessibleValue 122: { 123: private static final long serialVersionUID = -6301740148041106789L; 124: 125: /** 126: * Creates a new AccessibleJSlider object. 127: * 128: * @param value0 DOCUMENT ME! 129: */ 130: protected AccessibleJSlider() 131: { 132: } 133: 134: /** 135: * DOCUMENT ME! 136: * 137: * @return DOCUMENT ME! 138: */ 139: public AccessibleStateSet getAccessibleStateSet() 140: { 141: return null; 142: } 143: 144: /** 145: * DOCUMENT ME! 146: * 147: * @return DOCUMENT ME! 148: */ 149: public AccessibleRole getAccessibleRole() 150: { 151: return null; 152: } 153: 154: /** 155: * DOCUMENT ME! 156: * 157: * @return DOCUMENT ME! 158: */ 159: public AccessibleValue getAccessibleValue() 160: { 161: return null; 162: } 163: 164: /** 165: * DOCUMENT ME! 166: * 167: * @return DOCUMENT ME! 168: */ 169: public Number getCurrentAccessibleValue() 170: { 171: return null; 172: } 173: 174: /** 175: * setCurrentAccessibleValue 176: * 177: * @param value0 TODO 178: * 179: * @return boolean 180: */ 181: public boolean setCurrentAccessibleValue(Number value0) 182: { 183: return false; 184: } 185: 186: /** 187: * getMinimumAccessibleValue 188: * 189: * @return Number 190: */ 191: public Number getMinimumAccessibleValue() 192: { 193: return null; 194: } 195: 196: /** 197: * getMaximumAccessibleValue 198: * 199: * @return Number 200: */ 201: public Number getMaximumAccessibleValue() 202: { 203: return null; 204: } 205: } 206: 207: /** Whether or not this slider paints its ticks. */ 208: private transient boolean paintTicks = false; 209: 210: /** Whether or not this slider paints its track. */ 211: private transient boolean paintTrack = true; 212: 213: /** Whether or not this slider paints its labels. */ 214: private transient boolean paintLabels = false; 215: 216: /** 217: * A dictionary of (Integer, Component) pairs where each Component is a 218: * JLabel and the Integer determines where the label will be painted. 219: */ 220: private transient Dictionary labelTable; 221: 222: /** The model used to describe the slider. */ 223: protected BoundedRangeModel sliderModel; 224: 225: /** The space between major ticks. */ 226: protected int majorTickSpacing; 227: 228: /** The space between minor ticks. */ 229: protected int minorTickSpacing; 230: 231: /** Whether the slider snaps its values to ticks. */ 232: protected boolean snapToTicks = true; 233: 234: /** The orientation of the slider. */ 235: protected int orientation = HORIZONTAL; 236: 237: /** Whether the slider is inverted. */ 238: private transient boolean isInverted; 239: 240: /** The ChangeListener that listens to the model. */ 241: protected ChangeListener changeListener; 242: 243: /** The ChangeEvent that is passed to all listeners of this slider. */ 244: protected transient ChangeEvent changeEvent; 245: 246: /** 247: * Creates a new horizontal JSlider object with a minimum of 0, a maximum of 248: * 100, and a value of 50. 249: */ 250: public JSlider() 251: { 252: this(HORIZONTAL, 0, 100, 50); 253: } 254: 255: /** 256: * Creates a new JSlider object with the given orientation and a minimum of 257: * 0, a maximum of 100, and a value of 50. 258: * 259: * @param orientation The orientation of the slider. 260: */ 261: public JSlider(int orientation) 262: { 263: this(orientation, 0, 100, 50); 264: } 265: 266: /** 267: * Creates a new horizontal JSlider object with the given maximum and 268: * minimum and a value that is halfway between the minimum and the 269: * maximum. 270: * 271: * @param minimum The minimum value of the JSlider. 272: * @param maximum The maximum value of the JSlider. 273: */ 274: public JSlider(int minimum, int maximum) 275: { 276: this(HORIZONTAL, minimum, maximum, (maximum + minimum) / 2); 277: } 278: 279: /** 280: * Creates a new horizontal JSlider object with the given minimum, maximum, 281: * and value. 282: * 283: * @param minimum The minimum value of the JSlider. 284: * @param maximum The maximum value of the JSlider. 285: * @param value The initial value of the JSlider. 286: */ 287: public JSlider(int minimum, int maximum, int value) 288: { 289: this(HORIZONTAL, minimum, maximum, value); 290: } 291: 292: /** 293: * Creates a new JSlider object with the given orientation, minimum, 294: * maximum, and value. 295: * 296: * @param orientation The orientation of the JSlider. 297: * @param minimum The minimum value of the JSlider. 298: * @param maximum The maximum value of the JSlider. 299: * @param value The initial value of the JSlider. 300: */ 301: public JSlider(int orientation, int minimum, int maximum, int value) 302: { 303: sliderModel = new DefaultBoundedRangeModel(value, 0, minimum, maximum); 304: if (orientation != HORIZONTAL && orientation != VERTICAL) 305: throw new IllegalArgumentException(orientation + " is not a legal orientation"); 306: this.orientation = orientation; 307: changeListener = createChangeListener(); 308: sliderModel.addChangeListener(changeListener); 309: updateUI(); 310: } 311: 312: /** 313: * Creates a new horizontal JSlider object with the given model. 314: * 315: * @param model The model the slider will be created with. 316: */ 317: public JSlider(BoundedRangeModel model) 318: { 319: if (model == null) 320: sliderModel = new DefaultBoundedRangeModel(50, 0, 0, 100); 321: else 322: sliderModel = model; 323: changeListener = createChangeListener(); 324: sliderModel.addChangeListener(changeListener); 325: updateUI(); 326: } 327: 328: /** 329: * This method returns the current value of the slider. 330: * 331: * @return The value of the slider stored in the model. 332: */ 333: public int getValue() 334: { 335: return sliderModel.getValue(); 336: } 337: 338: /** 339: * This method sets the value of the slider. 340: * 341: * @param value The slider's new value. 342: */ 343: public void setValue(int value) 344: { 345: sliderModel.setValue(value); 346: } 347: 348: /** 349: * This method returns the slider's UI delegate. 350: * 351: * @return The slider's UI delegate. 352: */ 353: public SliderUI getUI() 354: { 355: return (SliderUI) ui; 356: } 357: 358: /** 359: * This method sets the slider's UI delegate. 360: * 361: * @param ui A SliderUI object to use with this slider. 362: */ 363: public void setUI(SliderUI ui) 364: { 365: super.setUI(ui); 366: } 367: 368: /** 369: * This method sets this slider's UI to the UIManager's default for the 370: * current look and feel. 371: */ 372: public void updateUI() 373: { 374: setUI((SliderUI) UIManager.getUI(this)); 375: invalidate(); 376: repaint(); 377: } 378: 379: /** 380: * This method returns a name to identify which look and feel class will be 381: * the UI delegate for the slider. 382: * 383: * @return The Look and Feel classID. "SliderUI" 384: */ 385: public String getUIClassID() 386: { 387: return "SliderUI"; 388: } 389: 390: /** 391: * Creates a ChangeListener for this Slider. 392: * 393: * @return A new ChangeListener. 394: */ 395: protected ChangeListener createChangeListener() 396: { 397: return new ChangeListener() 398: { 399: public void stateChanged(ChangeEvent ce) 400: { 401: // No need to trigger a repaint since the UI listens to the model 402: // as well. All we need to do is pass on the stateChanged event 403: // to our listeners. 404: fireStateChanged(); 405: } 406: }; 407: } 408: 409: /** 410: * This method registers a listener to this slider. The listener will be 411: * informed of new ChangeEvents. 412: * 413: * @param listener The listener to register. 414: */ 415: public void addChangeListener(ChangeListener listener) 416: { 417: listenerList.add(ChangeListener.class, listener); 418: } 419: 420: /** 421: * This method removes a listener from this slider. 422: * 423: * @param listener The listener to remove. 424: */ 425: public void removeChangeListener(ChangeListener listener) 426: { 427: listenerList.remove(ChangeListener.class, listener); 428: } 429: 430: /** 431: * This method is called whenever the model fires a ChangeEvent. It should 432: * propagate the ChangeEvent to its listeners with a new ChangeEvent that 433: * identifies the slider as the source. 434: */ 435: protected void fireStateChanged() 436: { 437: Object[] changeListeners = listenerList.getListenerList(); 438: if (changeEvent == null) 439: changeEvent = new ChangeEvent(this); 440: for (int i = changeListeners.length - 2; i >= 0; i -= 2) 441: { 442: if (changeListeners[i] == ChangeListener.class) 443: ((ChangeListener) changeListeners[i + 1]).stateChanged(changeEvent); 444: } 445: } 446: 447: /** 448: * This method returns an array of all ChangeListeners listening to this 449: * slider. 450: * 451: * @return An array of ChangeListeners listening to this slider. 452: */ 453: public ChangeListener[] getChangeListeners() 454: { 455: return (ChangeListener[]) listenerList.getListeners(ChangeListener.class); 456: } 457: 458: /** 459: * This method returns the model of the slider. 460: * 461: * @return The slider's model. 462: */ 463: public BoundedRangeModel getModel() 464: { 465: return sliderModel; 466: } 467: 468: /** 469: * This method changes the "model" property. It also needs to unregister 470: * any listeners to the old model and register any listeners to the new 471: * model. 472: * 473: * @param model The model to use with the slider. 474: */ 475: public void setModel(BoundedRangeModel model) 476: { 477: // I didn't do the null pointer check on purpose. 478: // If you try it with Sun's, it'll go ahead and set it to null 479: // and bork the next time it tries to access the model. 480: if (model != sliderModel) 481: { 482: BoundedRangeModel oldModel = sliderModel; 483: sliderModel = model; 484: oldModel.removeChangeListener(changeListener); 485: sliderModel.addChangeListener(changeListener); 486: firePropertyChange("model", oldModel, sliderModel); 487: } 488: } 489: 490: /** 491: * This method returns the minimum value of the slider. 492: * 493: * @return The minimum value of the slider. 494: */ 495: public int getMinimum() 496: { 497: return sliderModel.getMinimum(); 498: } 499: 500: /** 501: * This method sets the minimum value of the slider. 502: * 503: * @param minimum The minimum value of the slider. 504: */ 505: public void setMinimum(int minimum) 506: { 507: sliderModel.setMinimum(minimum); 508: } 509: 510: /** 511: * This method returns the maximum value of the slider. 512: * 513: * @return The maximum value of the slider. 514: */ 515: public int getMaximum() 516: { 517: return sliderModel.getMaximum(); 518: } 519: 520: /** 521: * This method sets the maximum value of the slider. 522: * 523: * @param maximum The maximum value of the slider. 524: */ 525: public void setMaximum(int maximum) 526: { 527: sliderModel.setMaximum(maximum); 528: } 529: 530: /** 531: * This method returns this slider's isAdjusting value which is true if the 532: * thumb is being dragged. 533: * 534: * @return The slider's isAdjusting value. 535: */ 536: public boolean getValueIsAdjusting() 537: { 538: return sliderModel.getValueIsAdjusting(); 539: } 540: 541: /** 542: * This method sets the isAdjusting value for the slider. 543: * 544: * @param adjusting The slider's isAdjusting value. 545: */ 546: public void setValueIsAdjusting(boolean adjusting) 547: { 548: sliderModel.setValueIsAdjusting(adjusting); 549: } 550: 551: /** 552: * This method returns the extent value for this slider. 553: * 554: * @return The extent value for this slider. 555: */ 556: public int getExtent() 557: { 558: return sliderModel.getExtent(); 559: } 560: 561: /** 562: * This method sets the extent value for this slider. 563: * 564: * @param extent The extent value for this slider. 565: */ 566: public void setExtent(int extent) 567: { 568: sliderModel.setExtent(extent); 569: } 570: 571: /** 572: * This method returns the slider orientation. 573: * 574: * @return The orientation of the slider. 575: */ 576: public int getOrientation() 577: { 578: return orientation; 579: } 580: 581: /** 582: * This method changes the "orientation" property of this slider. If the 583: * orientation is not VERTICAL or HORIZONTAL, this method does nothing. 584: * 585: * @param orientation The orientation of this slider. 586: */ 587: public void setOrientation(int orientation) 588: { 589: if (orientation != VERTICAL && orientation != HORIZONTAL) 590: throw new IllegalArgumentException("orientation must be one of: VERTICAL, HORIZONTAL"); 591: if (orientation != this.orientation) 592: { 593: int oldOrientation = this.orientation; 594: this.orientation = orientation; 595: firePropertyChange("orientation", oldOrientation, 596: this.orientation); 597: } 598: } 599: 600: /** 601: * This method returns the label table for this slider. 602: * 603: * @return The label table for this slider. 604: */ 605: public Dictionary getLabelTable() 606: { 607: return labelTable; 608: } 609: 610: /** 611: * This method changes the "labelTable" property of this slider. 612: * 613: * @param table The label table for this slider. 614: */ 615: public void setLabelTable(Dictionary table) 616: { 617: if (table != labelTable) 618: { 619: Dictionary oldTable = labelTable; 620: labelTable = table; 621: firePropertyChange("labelTable", oldTable, labelTable); 622: } 623: } 624: 625: /** 626: * This method is called to reset UI delegates for the labels in the 627: * labelTable to a default for the current look and feel. 628: */ 629: protected void updateLabelUIs() 630: { 631: if (labelTable == null) 632: return; 633: for (Enumeration list = labelTable.elements(); list.hasMoreElements();) 634: { 635: JLabel label = (JLabel) list.nextElement(); 636: label.updateUI(); 637: } 638: } 639: 640: /** 641: * Creates a hashtable of (Integer, JLabel) pairs that can be used as a 642: * label table for this slider. The labels will start from the sliders 643: * minimum and increase by the increment. Each label will have a text 644: * string indicating their integer value. 645: * 646: * @param increment The increment to between labels. 647: * 648: * @return A hashtable with the labels and their keys. 649: */ 650: public Hashtable createStandardLabels(int increment) 651: { 652: return createStandardLabels(increment, sliderModel.getMinimum()); 653: } 654: 655: /** 656: * Creates a hashtable of (Integer, JLabel) pairs that can be used as a 657: * label table for this slider. The labels will start from the given start 658: * value and increase by the increment. Each label will have a text string 659: * indicating their integer value. 660: * 661: * @param increment The increment to between labels. 662: * @param start The value to start from. 663: * 664: * @return A hashtable with the labels and their keys. 665: */ 666: public Hashtable createStandardLabels(int increment, int start) 667: { 668: Hashtable table = new Hashtable(); 669: JLabel label; 670: Dimension dim; 671: 672: int max = sliderModel.getMaximum(); 673: 674: for (int i = start; i <= max; i += increment) 675: { 676: label = new JLabel(String.valueOf(i)); 677: label.setVerticalAlignment(CENTER); 678: label.setHorizontalAlignment(CENTER); 679: 680: // Make sure these labels have the width and height 681: // they want. 682: dim = label.getPreferredSize(); 683: label.setBounds(label.getX(), label.getY(), 684: (int) dim.getWidth(), 685: (int) dim.getHeight()); 686: table.put(new Integer(i), label); 687: } 688: return table; 689: } 690: 691: /** 692: * This method returns whether the slider is inverted. Horizontal sliders 693: * that are not inverted will have the minimums on the left. If they are 694: * inverted, the minimums will be on the right. Vertical sliders that are 695: * not inverted will have the minimums at the bottom. If they are inverted, 696: * the minimums will be at the top. 697: * 698: * @return Whether this slider is inverted. 699: */ 700: public boolean getInverted() 701: { 702: return isInverted; 703: } 704: 705: /** 706: * This method changes the "inverted" property for this slider.Horizontal 707: * sliders that are not inverted will have the minimums on the left. If 708: * they are inverted, the minimums will be on the right. Vertical sliders 709: * that are not inverted will have the minimums at the bottom. If they are 710: * inverted, the minimums will be at the top. However, if the slider's 711: * componentOrientation is set to RIGHT_TO_LEFT, then everything gets 712: * reversed again. 713: * 714: * @param inverted Whether the slider should be inverted. 715: */ 716: public void setInverted(boolean inverted) 717: { 718: if (isInverted != inverted) 719: { 720: boolean oldInverted = isInverted; 721: isInverted = inverted; 722: firePropertyChange("inverted", oldInverted, isInverted); 723: } 724: } 725: 726: /** 727: * This method returns the amount of units between each major tick mark. 728: * 729: * @return The amount of units between each major tick mark. 730: */ 731: public int getMajorTickSpacing() 732: { 733: return majorTickSpacing; 734: } 735: 736: /** 737: * This method changes the "majorTickSpacing" property for this slider. The 738: * major tick spacing is the amount of units between each major tick mark. 739: * 740: * @param spacing The amount of units between each major tick mark. 741: */ 742: public void setMajorTickSpacing(int spacing) 743: { 744: if (majorTickSpacing != spacing) 745: { 746: int oldSpacing = majorTickSpacing; 747: majorTickSpacing = spacing; 748: firePropertyChange("majorTickSpacing", oldSpacing, 749: majorTickSpacing); 750: } 751: } 752: 753: /** 754: * This method returns the amount of units between each minor tick mark. 755: * 756: * @return The amount of units between each minor tick mark. 757: */ 758: public int getMinorTickSpacing() 759: { 760: return minorTickSpacing; 761: } 762: 763: /** 764: * This method changes the "minorTickSpacing" property for this slider. The 765: * minor tick spacing is the amount of units between each minor tick mark. 766: * 767: * @param spacing The amount of units between each minor tick mark. 768: */ 769: public void setMinorTickSpacing(int spacing) 770: { 771: if (minorTickSpacing != spacing) 772: { 773: int oldSpacing = minorTickSpacing; 774: minorTickSpacing = spacing; 775: firePropertyChange("minorTickSpacing", oldSpacing, 776: minorTickSpacing); 777: } 778: } 779: 780: /** 781: * This method returns whether this slider is snapping to ticks. Sliders 782: * that snap to ticks will automatically move the thumb to the nearest tick 783: * mark. 784: * 785: * @return Whether this slider snaps to ticks. 786: */ 787: public boolean getSnapToTicks() 788: { 789: return snapToTicks; 790: } 791: 792: /** 793: * This method sets whether this slider will snap to ticks. Sliders that 794: * snap to ticks will automatically move the thumb to the nearest tick 795: * mark. 796: * 797: * @param snap Whether this slider snaps to ticks. 798: */ 799: public void setSnapToTicks(boolean snap) 800: { 801: if (snap != snapToTicks) 802: { 803: snapToTicks = snap; 804: fireStateChanged(); 805: } 806: } 807: 808: /** 809: * This method returns whether the slider will paint its tick marks. In 810: * addition to setting this property to true, one of minor tick spacing or 811: * major tick spacing must be set to a value greater than 0 in order for 812: * ticks to be painted. 813: * 814: * @return Whether ticks will be painted. 815: */ 816: public boolean getPaintTicks() 817: { 818: return paintTicks; 819: } 820: 821: /** 822: * This method changes the "paintTicks" property for this slider. In 823: * addition to setting this property to true, one of minor tick spacing or 824: * major tick spacing must be set to a value greater than 0 in order for 825: * ticks to be painted. 826: * 827: * @param paint Whether ticks will be painted. 828: */ 829: public void setPaintTicks(boolean paint) 830: { 831: if (paint != paintTicks) 832: { 833: boolean oldPaintTicks = paintTicks; 834: paintTicks = paint; 835: firePropertyChange("paintTicks", oldPaintTicks, paintTicks); 836: } 837: } 838: 839: /** 840: * This method returns whether the track will be painted. 841: * 842: * @return Whether the track will be painted. 843: */ 844: public boolean getPaintTrack() 845: { 846: return paintTrack; 847: } 848: 849: /** 850: * This method sets whether the track will be painted. 851: * 852: * @param paint Whether the track will be painted. 853: */ 854: public void setPaintTrack(boolean paint) 855: { 856: paintTrack = paint; 857: } 858: 859: /** 860: * This method returns whether labels will be painted. 861: * 862: * @return Whether labels will be painted. 863: */ 864: public boolean getPaintLabels() 865: { 866: return paintLabels; 867: } 868: 869: /** 870: * This method changes the "paintLabels" property. 871: * 872: * @param paint Whether labels will be painted. 873: */ 874: public void setPaintLabels(boolean paint) 875: { 876: if (paint != paintLabels) 877: { 878: boolean oldPaintLabels = paintLabels; 879: paintLabels = paint; 880: firePropertyChange("paintLabels", oldPaintLabels, paintLabels); 881: } 882: } 883: 884: /** 885: * This method is used primarily for debugging purposes and returns a string 886: * that can be used to represent this slider. 887: * 888: * @return A string representing this slider. 889: */ 890: protected String paramString() 891: { 892: return "JSlider"; 893: } 894: 895: /** 896: * DOCUMENT ME! 897: * 898: * @return DOCUMENT ME! 899: */ 900: public AccessibleContext getAccessibleContext() 901: { 902: if (accessibleContext == null) 903: accessibleContext = new AccessibleJSlider(); 904: 905: return accessibleContext; 906: } 907: }
GNU Classpath (0.17) |