Click to See Complete Forum and Search --> : Text in a Java GUI


Lucefiel
01-24-2001, 03:33 PM
I've just started taking a Java class and, because the language is just so dang similar to C++, I've begun jumping ahead. I've also encountered a problem.

I can't get text, just plain text, to show up the way I want in my GUI window. Is there a method that works like System.out.println() and allows you to type text and have it appear exactly how you type it? Or do you have to jump through hoops to get it that way?

I've tried several ways of writing the text to the window, but I can't figure out how to format any of the output (like adding line feeds).

Somebody help me!

------------------
May the best of your past be the worst of your future.

BrianDrozd
01-24-2001, 05:36 PM
In later versions of Java (1.1 and above, I think) there is a Java\Lang\Text (?) package that should allow you to do the formating. (Sorry, but I haven't used it much, myself, so I can't tell you more about it.)

nanode
01-24-2001, 06:42 PM
JLabels can even use HTML tags for formatting:
http://java.sun.com/j2se/1.3/docs/api/index.html

It all depends on what exactly you want to do. If you want to display a long string with linefeeds etc. I'd suggest using a JTextArea. You can force just about anything, but placing a paragraph onto a button doesn't seem reasonable http://www.linuxnewbie.org/ubb/smile.gif