Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-27-2008, 07:49 PM
Member
 
Join Date: Mar 2008
Posts: 9
perplexingtrax is on a distinguished road
new line within a string
Hi, when my applet calls the string to display the description of something, of course it prints out a long line, which is bad because the string is a paragraph long and i want it be in lines. I have played with the + /n + command but it doesnt affect it and prints out the long line still?

My string is-
String TentDesc [] = {"blah....................... blah............................... blah"}

I have tried playing with the + /n + postioning but to no avail?

Maybe because its in an applet, will i have to somehow loop it to start a line down after so many chars have been printed? Or would it be easier to just fill a text box?

Any ideas of the best or standard way this is done?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-27-2008, 08:01 PM
Member
 
Join Date: Mar 2008
Posts: 9
perplexingtrax is on a distinguished road
btw its a java awt applet, not swing
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 03-28-2008, 04:30 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,402
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Did you use "" within your string literals?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 03-28-2008, 02:50 PM
DonCash's Avatar
Moderator
 
Join Date: Aug 2007
Location: London, UK
Posts: 239
DonCash will become famous soon enoughDonCash will become famous soon enough
Hey perplexingtrax.

Instead of using /n use this:

Code:
String newline = System.getProperty("line.separator");
So your code should look something like this:

Code:
String newline = System.getProperty("line.separator"); String TentDesc[] = "blah.." + newline + "blah.." + newline + "blah.."
Sorted
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 03-28-2008, 10:07 PM
Member
 
Join Date: Mar 2008
Posts: 9
perplexingtrax is on a distinguished road
Thanks DonCash but that doesn't seem to affect the string when i call paint in the applet, its still a sentence. My string is something like this now-

String TentDesc [] =
{"blah....................... blah............................... blah",
"blah....................... blah............................... blah",
"blah....................... blah............................... blah",
};

its put through actionPerformed in a for loop and given the value
message =(TentDesc[j]);

i called it in paint like
g.drawString(message,900, 100);

Eranga
i think i do use them yes
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 03-30-2008, 11:16 PM
Member
 
Join Date: Mar 2008
Posts: 9
perplexingtrax is on a distinguished road
i have it now going into a TextField. any idea's how to set the text wrapping in the text box? thanks
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 03-31-2008, 05:46 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,402
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
If you mean about multiple text lines on a TextFeild I don't think it is possible. You may use TextArea. There you can use multiple lines for text.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
print line kazitula Java Applets 2 01-26-2008 04:05 PM
Using java.util.Scanner to search for a String in a String Java Tip Java Tips 0 11-20-2007 06:59 PM
Reading in data from file line by line bluekswing New To Java 1 10-02-2007 02:19 AM
Help with insertName(String name) and deleteName(String name) trill New To Java 1 08-07-2007 09:29 AM
I can't seem to pass the value of a string variable into a string array mathias Java Applets 1 08-03-2007 12:52 PM


All times are GMT +3. The time now is 04:46 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org