This patch (committed) adds more attribute details to the paramString() method in
the JLabel class. I also added two helper methods to SwingUtilities (if there's a
better place to put these, let me know and I'll move them):
2006-05-09 David Gilbert <[EMAIL PROTECTED]>
* javax/swing/JLabel.java
(paramString): Added more attribute details,
* javax/swing/SwingUtilities.java
(convertHorizontalAlignmentCodeToString): New method,
(convertVerticalAlignmentCodeToString): New method.
Regards,
Dave
Index: javax/swing/JLabel.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/JLabel.java,v
retrieving revision 1.32
diff -u -r1.32 JLabel.java
--- javax/swing/JLabel.java 4 May 2006 19:08:53 -0000 1.32
+++ javax/swing/JLabel.java 9 May 2006 07:11:37 -0000
@@ -1,5 +1,5 @@
/* JLabel.java --
- Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -297,7 +297,6 @@
}
}
- /** DOCUMENT ME! */
private static final long serialVersionUID = 5496508283662221534L;
static final String LABEL_PROPERTY = "labeledBy";
@@ -452,14 +451,42 @@
}
/**
- * This method is used primarily for debugging purposes and returns a string
- * that can be used to represent this label.
+ * Returns a string describing the attributes for the <code>JLabel</code>
+ * component, for use in debugging. The return value is guaranteed to be
+ * non-<code>null</code>, but the format of the string may vary between
+ * implementations.
*
- * @return A string to represent this label.
+ * @return A string describing the attributes of the <code>JLabel</code>.
*/
protected String paramString()
{
- return super.paramString();
+ StringBuffer sb = new StringBuffer(super.paramString());
+ sb.append(",defaultIcon=");
+ if (icon != null)
+ sb.append(icon);
+ sb.append(",disabledIcon=");
+ if (disabledIcon != null)
+ sb.append(disabledIcon);
+ sb.append(",horizontalAlignment=");
+ sb.append(SwingUtilities.convertHorizontalAlignmentCodeToString(
+ horizontalAlignment));
+ sb.append(",horizontalTextPosition=");
+ sb.append(SwingUtilities.convertHorizontalAlignmentCodeToString(
+ horizontalTextPosition));
+ sb.append(",iconTextGap=").append(iconTextGap);
+ sb.append(",labelFor=");
+ if (labelFor != null)
+ sb.append(labelFor);
+ sb.append(",text=");
+ if (text != null)
+ sb.append(text);
+ sb.append(",verticalAlignment=");
+ sb.append(SwingUtilities.convertVerticalAlignmentCodeToString(
+ verticalAlignment));
+ sb.append(",verticalTextPosition=");
+ sb.append(SwingUtilities.convertVerticalAlignmentCodeToString(
+ verticalTextPosition));
+ return sb.toString();
}
/**
@@ -902,9 +929,10 @@
}
/**
- * DOCUMENT ME!
+ * Returns the object that provides accessibility features for this
+ * <code>JLabel</code> component.
*
- * @return The accessible context.
+ * @return The accessible context (an instance of [EMAIL PROTECTED]
AccessibleJLabel}).
*/
public AccessibleContext getAccessibleContext()
{
Index: javax/swing/SwingUtilities.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/SwingUtilities.java,v
retrieving revision 1.51
diff -u -r1.51 SwingUtilities.java
--- javax/swing/SwingUtilities.java 3 May 2006 14:29:45 -0000 1.51
+++ javax/swing/SwingUtilities.java 9 May 2006 07:11:39 -0000
@@ -1446,4 +1446,106 @@
KeyboardManager km = KeyboardManager.getManager();
return km.processKeyStroke(c, s, ev);
}
+
+ /**
+ * Returns a string representing one of the horizontal alignment codes
+ * defined in the [EMAIL PROTECTED] SwingConstants} interface. The
following table
+ * lists the constants and return values:
+ * <p>
+ * <table border="0">
+ * <tr>
+ * <th>Code:</th><th>Returned String:</th>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] SwingConstants#CENTER}</td>
+ * <td><code>"CENTER"</code></td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] SwingConstants#LEFT}</td>
+ * <td><code>"LEFT"</code></td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] SwingConstants#RIGHT}</td>
+ * <td><code>"RIGHT"</code></td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] SwingConstants#LEADING}</td>
+ * <td><code>"LEADING"</code></td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] SwingConstants#TRAILING}</td>
+ * <td><code>"TRAILING"</code></td>
+ * </tr>
+ * </table>
+ * </p>
+ * If the supplied code is not one of those listed, this methods will throw
+ * an [EMAIL PROTECTED] IllegalArgumentException}.
+ *
+ * @param code the code.
+ *
+ * @return A string representing the given code.
+ */
+ static String convertHorizontalAlignmentCodeToString(int code)
+ {
+ switch (code)
+ {
+ case SwingConstants.CENTER:
+ return "CENTER";
+ case SwingConstants.LEFT:
+ return "LEFT";
+ case SwingConstants.RIGHT:
+ return "RIGHT";
+ case SwingConstants.LEADING:
+ return "LEADING";
+ case SwingConstants.TRAILING:
+ return "TRAILING";
+ default:
+ throw new IllegalArgumentException("Unrecognised code: " + code);
+ }
+ }
+
+ /**
+ * Returns a string representing one of the vertical alignment codes
+ * defined in the [EMAIL PROTECTED] SwingConstants} interface. The
following table
+ * lists the constants and return values:
+ * <p>
+ * <table border="0">
+ * <tr>
+ * <th>Code:</th><th>Returned String:</th>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] SwingConstants#CENTER}</td>
+ * <td><code>"CENTER"</code></td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] SwingConstants#TOP}</td>
+ * <td><code>"TOP"</code></td>
+ * </tr>
+ * <tr>
+ * <td>[EMAIL PROTECTED] SwingConstants#BOTTOM}</td>
+ * <td><code>"BOTTOM"</code></td>
+ * </tr>
+ * </table>
+ * </p>
+ * If the supplied code is not one of those listed, this methods will throw
+ * an [EMAIL PROTECTED] IllegalArgumentException}.
+ *
+ * @param code the code.
+ *
+ * @return A string representing the given code.
+ */
+ static String convertVerticalAlignmentCodeToString(int code)
+ {
+ switch (code)
+ {
+ case SwingConstants.CENTER:
+ return "CENTER";
+ case SwingConstants.TOP:
+ return "TOP";
+ case SwingConstants.BOTTOM:
+ return "BOTTOM";
+ default:
+ throw new IllegalArgumentException("Unrecognised code: " + code);
+ }
+ }
}