Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Bold and Underline User Input

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 4739
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using the following to ask for the number:

 
Norm Radder
Rancher
Posts: 4739
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes sorry.  I made certain assumptions and I really need to stop that lol

 
Marshal
Posts: 75676
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
if you think brussel sprouts are yummy, you should try any other food. And this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic