From da8792193f6f9e965657652e112f61db709e8418 Mon Sep 17 00:00:00 2001 From: David Gilbert Date: Tue, 19 Jul 2005 13:20:37 +0000 Subject: 2005-17-19 David Gilbert * javax/swing/JSlider.java (createStandardLabels(int)): updated API docs, (createStandardLabels(int, int)): throw IllegalArgumentException for bad arguments. --- javax/swing/JSlider.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'javax/swing/JSlider.java') diff --git a/javax/swing/JSlider.java b/javax/swing/JSlider.java index 2187311d9..1761b31af 100644 --- a/javax/swing/JSlider.java +++ b/javax/swing/JSlider.java @@ -648,9 +648,12 @@ public class JSlider extends JComponent implements SwingConstants, Accessible, * minimum and increase by the increment. Each label will have a text * string indicating their integer value. * - * @param increment The increment to between labels. + * @param increment The increment between labels (must be > 0). * * @return A hashtable with the labels and their keys. + * + * @throws IllegalArgumentException if increment is not greater + * than zero. */ public Hashtable createStandardLabels(int increment) { @@ -661,15 +664,23 @@ public class JSlider extends JComponent implements SwingConstants, Accessible, * Creates a hashtable of (Integer, JLabel) pairs that can be used as a * label table for this slider. The labels will start from the given start * value and increase by the increment. Each label will have a text string - * indicating their integer value. + * indicating its integer value. * - * @param increment The increment to between labels. + * @param increment The increment between labels (must be > 0). * @param start The value to start from. * * @return A hashtable with the labels and their keys. + * + * @throws IllegalArgumentException if increment is not greater + * than zero, or start is not within the range of the + * model. */ public Hashtable createStandardLabels(int increment, int start) { + if (increment <= 0) + throw new IllegalArgumentException("Requires 'increment' > 0."); + if (start < getMinimum() || start > getMaximum()) + throw new IllegalArgumentException("The 'start' value is out of range."); Hashtable table = new Hashtable(); JLabel label; Dimension dim; -- cgit v1.2.1