• Post Reply Bookmark Topic Watch Topic
  • New Topic

Bold and Underline User Input  RSS feed

 
Trey Burkhalter
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing some code for a class project.  I have main parts done, but I am just trying to add the extras that the professor has eluded to.  How would I bold and underline the text as they enter it?

IE:   Enter number of boxes: 3
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That would require a component that allows a user to enter data and that supported some kind of markup the code could wrap around the user's input.
I don't currently know of a component that does that.  Maybe someone with better Swing/JavaFX knowledge will come along.
Maybe the JEditorPane class would be of use.
 
Trey Burkhalter
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the following to ask for the number:

 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is input a Scanner object reading from System.in?

I don't think its easy or even possible to control what the OS does to display text that is entered on a console.
And it is not part of java.
 
Trey Burkhalter
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes sorry.  I made certain assumptions and I really need to stop that lol

 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Norm Radder wrote:. . . I don't currently know of a component that does that.  . . .
As far as I remember, you can put basic HTML tags onto a JLabel. There are ways to get a terminal to show bold or underlined text, but that is complicated and I can't remember how to do it, and it is platform‑specific.
Remove the keywords public and static from the code you showed. The error message might go on about non‑static and it makes people think the answer is to mark something static. But the correct solution is to remove the code using it from a static context.

And welcome to the Ranch
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!