diff options
Diffstat (limited to 'libjava/classpath/javax/swing/SwingUtilities.java')
-rw-r--r-- | libjava/classpath/javax/swing/SwingUtilities.java | 153 |
1 files changed, 153 insertions, 0 deletions
diff --git a/libjava/classpath/javax/swing/SwingUtilities.java b/libjava/classpath/javax/swing/SwingUtilities.java index 9d8e8df38f5..5d02d9bb396 100644 --- a/libjava/classpath/javax/swing/SwingUtilities.java +++ b/libjava/classpath/javax/swing/SwingUtilities.java @@ -1446,4 +1446,157 @@ public class SwingUtilities KeyboardManager km = KeyboardManager.getManager(); return km.processKeyStroke(c, s, ev); } + + /** + * Returns a string representing one of the horizontal alignment codes + * defined in the {@link 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>{@link SwingConstants#CENTER}</td> + * <td><code>"CENTER"</code></td> + * </tr> + * <tr> + * <td>{@link SwingConstants#LEFT}</td> + * <td><code>"LEFT"</code></td> + * </tr> + * <tr> + * <td>{@link SwingConstants#RIGHT}</td> + * <td><code>"RIGHT"</code></td> + * </tr> + * <tr> + * <td>{@link SwingConstants#LEADING}</td> + * <td><code>"LEADING"</code></td> + * </tr> + * <tr> + * <td>{@link 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 {@link 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 {@link 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>{@link SwingConstants#CENTER}</td> + * <td><code>"CENTER"</code></td> + * </tr> + * <tr> + * <td>{@link SwingConstants#TOP}</td> + * <td><code>"TOP"</code></td> + * </tr> + * <tr> + * <td>{@link 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 {@link 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); + } + } + + /** + * Returns a string representing one of the default operation codes + * defined in the {@link WindowConstants} 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>{@link WindowConstants#DO_NOTHING_ON_CLOSE}</td> + * <td><code>"DO_NOTHING_ON_CLOSE"</code></td> + * </tr> + * <tr> + * <td>{@link WindowConstants#HIDE_ON_CLOSE}</td> + * <td><code>"HIDE_ON_CLOSE"</code></td> + * </tr> + * <tr> + * <td>{@link WindowConstants#DISPOSE_ON_CLOSE}</td> + * <td><code>"DISPOSE_ON_CLOSE"</code></td> + * </tr> + * <tr> + * <td>{@link WindowConstants#EXIT_ON_CLOSE}</td> + * <td><code>"EXIT_ON_CLOSE"</code></td> + * </tr> + * </table> + * </p> + * If the supplied code is not one of those listed, this method will throw + * an {@link IllegalArgumentException}. + * + * @param code the code. + * + * @return A string representing the given code. + */ + static String convertWindowConstantToString(int code) + { + switch (code) + { + case WindowConstants.DO_NOTHING_ON_CLOSE: + return "DO_NOTHING_ON_CLOSE"; + case WindowConstants.HIDE_ON_CLOSE: + return "HIDE_ON_CLOSE"; + case WindowConstants.DISPOSE_ON_CLOSE: + return "DISPOSE_ON_CLOSE"; + case WindowConstants.EXIT_ON_CLOSE: + return "EXIT_ON_CLOSE"; + default: + throw new IllegalArgumentException("Unrecognised code: " + code); + } + } } |