PromptTextFieldUI extends PromptTextUI { @Override public JTextComponent getPromptComponent(JTextComponent txt) { LabelField lbl = (LabelField) super.getPromptComponent(txt); JTextField txtField = (JTextField) txt; lbl.setHorizontalAlignment(txtField.getHorizontalAlignment()); lbl.setColumns(txtField.getColumns()); lbl.hasFocus = txtField.hasFocus() && NativeSearchFieldSupport.isNativeSearchField(txtField); NativeSearchFieldSupport.setSearchField(lbl, NativeSearchFieldSupport .isSearchField(txtField)); NativeSearchFieldSupport.setFindPopupMenu(lbl, NativeSearchFieldSupport .getFindPopupMenu(txtField)); Border b = txt.getBorder(); if (b == null) { lbl.setBorder(txt.getBorder()); } else { Insets insets = b.getBorderInsets(txt); lbl.setBorder( createEmptyBorder(insets.top, insets.left, insets.bottom, insets.right)); } return lbl; } PromptTextFieldUI(TextUI delegate); @Override JTextComponent getPromptComponent(JTextComponent txt);  }
@Override @Test public void testGetLabelComponent() { super.testGetLabelComponent(); txtField.setHorizontalAlignment(JTextField.CENTER); JTextField lbl = (JTextField) ui.getPromptComponent(txtField); assertEquals(txtField.getHorizontalAlignment(), lbl.getHorizontalAlignment()); assertEquals(txtField.getColumns(), lbl.getColumns()); }