简体   繁体   中英

Prompt text for JFormattedTextField is not working

I wanted to add a text prompt for my JFormattedTextField and I searched it on google on how I could do this. I got a lot of hits for the following code below but when I put it into my code in eclipse it doesn't recognize any of it. Can someone tell me why?

Here are two possible ways to add a text prompt:

  PromptSupport.setPrompt("prompt", textComponent);
  TextPrompt p = new TextPrompt("text", textComponent);

I got it from the following link: How to display a default message in JTextField java

the most probable reasons why eclipse doesn't recognize any of these classes are because they are not a part of the JDK .

PromptSupport is a part of the XSwingX library. If you want to use this library for setting PromptText, you will have to download the jar and add it to the build path of the project.

I am not sure whether TextPrompt is the class XSwingX as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM