I am using JtextPane as a JTextField to make use of Html for styling..but I cant implement prompt text functionality..here is my code...
JTextPane txtNm = new JTextPane();
txtNm.setContentType("text/html");
txtNm.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent arg0) {
if(txtNm.getText().equals("<html><font face='Tw Cen MT' size='4' color='GRAY'> NAME</font><font color='red'> *</font></html>")){
txtNm.setText("");
//System.out.println("in txtnmfocus");
txtNm.setForeground(Color.decode("#003366"));
}
}
@Override
public void focusLost(FocusEvent e) {
if(txtNm.getText().isEmpty()){
txtNm.setText("<html><font face='Tw Cen MT' size='4' color='GRAY'> NAME</font><font color='red'> *</font></html>");
}
}
});