简体   繁体   中英

Hovering Dialogue Box

I am creating a log in form in Java. I have already completed the entire structure of the program, as well, I have designed it's purpose and perfected it's functionality. However, now I am focusing on styling the program. I'm proud of it as it is and it's fine if I don't add this feature, however I really would like to and cannot discover how.

In summary, when a username is typed into the login form, I have a void that runs after the JTextField loses focus. This void searches for possible invalid characters such as spaces. I can successfully change the color of the border on my JTextField, and other attributes I wish to change, however I also would like to have a small dialogue box to hover over the JTextField to say what specifically is wrong with what was typed. (eg "Your username cannot contain spaces!").

Ideally, it would be a rectangle that could simply be filled with text, and only appear when the username is deemed incorrect, and be able to disappear when it is fixed ( I can handle the appearance and disappearance most likely, I just need help with creating this box thing ).

Is there any such thing as like a "JHoverBox" or something that I could add to my JTextField?

Well, you can have, as Gene said, a label that's normally empty near the text field, but you can have it coloured like the background colour. This will make the user not able to see it, and when you detect something wrong, you can change the colour and add the text. Simple!

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