PromptSupport { public static void init(String promptText, Color promptForeground, Color promptBackground, final JTextComponent textComponent) { if (promptText != null && promptText.length() > 0) { setPrompt(promptText, textComponent); } if (promptForeground != null) { setForeground(promptForeground, textComponent); } if (promptBackground != null) { setBackground(promptBackground, textComponent); } } private  PromptSupport(); static void init(String promptText, Color promptForeground, Color promptBackground,
			final JTextComponent textComponent); static FocusBehavior getFocusBehavior(JTextComponent textComponent); static void setFocusBehavior(FocusBehavior focusBehavior, JTextComponent textComponent); static String getPrompt(JTextComponent textComponent); static void setPrompt(String promptText, JTextComponent textComponent); static Color getForeground(JTextComponent textComponent); static void setForeground(Color promptTextColor, JTextComponent textComponent); static Color getBackground(JTextComponent textComponent); static void setBackground(Color background, JTextComponent textComponent); @SuppressWarnings("unchecked") static Painter<? super T> getBackgroundPainter(T textComponent); static void setBackgroundPainter(Painter<? super T> background, T textComponent); static void setFontStyle(Integer fontStyle, JTextComponent textComponent); static Integer getFontStyle(JTextComponent textComponent); static final String PROMPT; static final String FOREGROUND; static final String BACKGROUND; static final String BACKGROUND_PAINTER; static final String FOCUS_BEHAVIOR; static final String FONT_STYLE; }
@Test public void testInit() { PromptSupport.init("test", Color.LIGHT_GRAY, Color.YELLOW, txt); assertEquals("test", PromptSupport.getPrompt(txt)); assertEquals("test", txt.getClientProperty(PromptSupport.PROMPT)); assertEquals(Color.LIGHT_GRAY, PromptSupport.getForeground(txt)); assertEquals(Color.LIGHT_GRAY, txt.getClientProperty(PromptSupport.FOREGROUND)); assertEquals(Color.YELLOW, PromptSupport.getBackground(txt)); assertEquals(Color.YELLOW, txt.getClientProperty(PromptSupport.BACKGROUND)); }
@Test public void testInitEmpty() { PromptSupport.init(null, null, null, txt); Assert.assertNotSame("PromptSupport should not be installed, unless it is necessary.", PromptTextFieldUI.class, txt.getUI().getClass()); }