This discussion is archived
1 2 3 Previous Next 38 Replies Latest reply: Jan 27, 2011 7:03 PM by EJP RSS

Use of formatting when printing strings

834337 Newbie
Currently Being Moderated
I would like to know how to print a string that is italicized. I am open to ideas involving complicated methods .. good to learn something new.
  • 1. Re: Use of formatting when printing strings
    PhHein Guru Moderator
    Currently Being Moderated
    Print on paper, on the console, in a GUI?
  • 2. Re: Use of formatting when printing strings
    834337 Newbie
    Currently Being Moderated
    My apologies, I thought the question was transparently posed within the 'Java Programming' forum implying "within Java". Indeed, I want to print to the console selective italicized print; that's the IDE console I am using and not a console such as a hand-held game or an actual terminal as part of a client/server configuration -- I jest of course but help is greatly appreciated. I want to be a little fancy with my code.
  • 3. Re: Use of formatting when printing strings
    Kayaman Guru
    Currently Being Moderated
    831334 wrote:
    My apologies, I thought the question was transparently posed within the 'Java Programming' forum implying "within Java".
    "Within Java" doesn't tell whether you want to print using a printer, on the console or the GUI.
    Indeed, I want to print to the console selective italicized print; that's the IDE console I am using and not a console such as a hand-held game or an actual terminal as part of a client/server configuration -- I jest of course but help is greatly appreciated.
    The console doesn't support italics in the general sense. It would involve terminal dependent control characters, which the IDE console would most likely not support anyway.
    I want to be a little fancy with my code.
    I think it's a bit too early for that.
  • 4. Re: Use of formatting when printing strings
    PhHein Guru Moderator
    Currently Being Moderated
    Short answer: no.

    All output going through the regular output streams as System.out cannot be formatted.
  • 5. Re: Use of formatting when printing strings
    796440 Guru
    Currently Being Moderated
    Kayaman wrote:
    831334 wrote:
    I want to be a little fancy with my code.
    I think it's a bit too early for that.
    Yup. In the same fashion as the first trimester in the womb is a little early to be learning to do a triple Salchow.
  • 6. Re: Use of formatting when printing strings
    800330 Explorer
    Currently Being Moderated
    All the other posters are right, you're probably too inexperienced to pull this off. A great source for picking up How to's are the Java tutorials on the Oracle pages. Knowing where to find the answer, is an important ingredient of the solution, so here's a pointer that could be relevant to your problem at hand: the [url http://download.oracle.com/javase/tutorial/uiswing/components/generaltext.html]Swing tutorial on text components. There's a lot more out there ranging from much more basic java programming to the really hard stuff. Good luck!
  • 7. Re: Use of formatting when printing strings
    834337 Newbie
    Currently Being Moderated
    Well I am a graduate student in Computer Science currently building from scratch a database program as part of my school database class I am taking this semester. I have taken undergraduate courses in Java covering simple types, and data structures; at the graduate level algorithm analysis covering topics such as Fourier Transforms. I am also engaged in improving my C programming skills and learning Python to boot.

    When I originally posted I thought I would receive an answer to my question regardless where I posted; perhaps this forum would be more active and relevant for my question. Now that my resume is out there including a background in electrical engineering, should I hit Google or can I get an answer to my question?

    If not the current adage is: "Its easy, just Google it" will suffice and follows the wade through data overload but oh well.
  • 8. Re: Use of formatting when printing strings
    PhHein Guru Moderator
    Currently Being Moderated
    Which parts of replies #3 and #4 didn't you understand?
  • 9. Re: Use of formatting when printing strings
    Kayaman Guru
    Currently Being Moderated
    831334 wrote:
    Well I am a graduate student in Computer Science currently building from scratch a database program as part of my school database class I am taking this semester. I have taken undergraduate courses in Java covering simple types, and data structures; at the graduate level algorithm analysis covering topics such as Fourier Transforms. I am also engaged in improving my C programming skills and learning Python to boot.
    Well that's nice for you, but I doubt many will be impressed here.
    When I originally posted I thought I would receive an answer to my question regardless where I posted; perhaps this forum would be more active and relevant for my question. Now that my resume is out there including a background in electrical engineering, should I hit Google or can I get an answer to my question?
    Now I know that one shouldn't expect much eloquence from a computer scientist, but your original question of "How can I print Strings in italics" wasn't exceptionally well thought out. Or was it news to you that Java is capable of outputting Strings in more ways than outputting to a standard console?
    If not the current adage is: "Its easy, just Google it" will suffice and follows the wade through data overload but oh well.
    We gave you plenty of answers already, do we need to hold a lecture for you to understand them?
  • 10. Re: Use of formatting when printing strings
    834337 Newbie
    Currently Being Moderated
    Curious, do you even have an answer of how I may display Strings as italics in Java? Console is a no go? Here is a well phrased and thought out question for you: Is Swing the only way to format text using italics in Java?, meaning, the language: you may still be confused as if I am referring to a printer but I think you can understand my question.

    Perhaps you will also not make assumptions if you answer the question concerned I may not have yer learned control loops or how to spell Arrey. Nevertheless, this trite was entertaining.
  • 11. Re: Use of formatting when printing strings
    PhHein Guru Moderator
    Currently Being Moderated
    You can format String output with AWT, Swing, SWT and other GUI toolkits.
  • 12. Re: Use of formatting when printing strings
    834337 Newbie
    Currently Being Moderated
    PhHein wrote:
    You can format String output with AWT, Swing, SWT and other GUI toolkits.
    Marked Helpful and thank you. I also appreciate knowing that console output can not attribute special formatting. I will consult the Abstract Window Toolkit, Swing structs, Standard Window Toolkit, and other GUI toolkits. I plan to add a GUI component to this project so again, thank you for answering damn question.
  • 13. Re: Use of formatting when printing strings
    Kayaman Guru
    Currently Being Moderated
    831334 wrote:
    Curious, do you even have an answer of how I may display Strings as italics in Java?
    I would have had several answers, had your question been formed properly. As was in several posts indicated, you can display italics text in a GUI or you could send italicized text to a printer.
    Both are valid ways and both are "in Java", which is a term that you're throwing out like candy, without really understanding what it means.
    Console is a no go?
    Like I said, it would depend on the terminal and its capabilities. I wouldn't say it's impossible, but it wouldn't be worth it. And the IDE's console is usually text-only.
    but I think you can understand my question.
    Well, I'm pretty good at deciphering people's ramblings here, and you seem to be even a native English speaker unlike so many people here.
    Perhaps you will also not make assumptions if you answer the question concerned I may not have yer learned control loops or how to spell Arrey.
    Could you rephrase that?
    Nevertheless, this trite was entertaining.
    Only for you, I assure that.


    --
    I wish we could mark the question askers as "unhelpful" or "unclear".

    Edited by: Kayaman on Jan 26, 2011 1:37 PM
  • 14. Re: Use of formatting when printing strings
    sabre150 Expert
    Currently Being Moderated
    831334 wrote:
    I also appreciate knowing that console output can not attribute special formatting.
    This is not a feature peculiar to Java since on Windows or Linux or pretty much any OS. Java just uses the console (or equivalent on your OS) which is a very very dumb terminal. Any program in any language writing to it will have the same problem. It is possible to install software that emulates a VTxxx terminal or other random access terminals but this make little sense these days. Best just to consider using Swing or AWT.

    Note - like the others who responded, I think that your original question was badly represented. It gave me the impression that you were very very new to programming and did not understand your OS console and how programs interacted with it.
1 2 3 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points