permaculture playing cards*
The moose likes Swing / AWT / SWT and the fly likes next line in swings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "next line in swings" Watch "next line in swings" New topic
Author

next line in swings

Hamsagayathri Palanisamy
Ranch Hand

Joined: Mar 10, 2008
Posts: 44
hi,
can any one please say me the equivalent for "\n" in Swings.
because i'm having the data in JTable like
For Example

Apple Mango orange

i need the output format like
Apple
mango
orange
please help me out..

-Thanks & Regards,
Hamsa
Stuart Smith
Ranch Hand

Joined: Mar 28, 2008
Posts: 54
I had this problem with Jlabel the way I found around it was to use HTML as the text instead of plain text as follows.

<html><body>test<br>test<body></html>

the <br> tag creates a new line break.

just wrap up your label Strings in HTML and it will work


Dale Carnegie:<br />"Most of the important things in the world have been accomplished<br />by people who have kept on trying when there seemed to be no hope at all."
Hamsagayathri Palanisamy
Ranch Hand

Joined: Mar 10, 2008
Posts: 44
Thanks for your reply.But, what i meant is,
I have created JTable as follows.
String fields[] = {"column 1", "column 2","column 3"};
int i=0;

ResultSet rs = preparedStmt.executeQuery();

while(rs.next())
{
for(int j=0;j<3;j++)
{
data[i][j] = rs.getString(j+1);
i++;
}
}

In data[n][1] where 'n' may be any value ..
i'm having value as "Apple Orange Mango" but i want as
Apple
Orange
Mango
JTable jt = new JTable( data, fields );
where 'fields' represents columns.
please help me out.

-Thanks & Regards,
Hamsa
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10175
    
    8

Originally posted by Hamsagayathri Palanisamy:
In data[n][1] where 'n' may be any value ..
i'm having value as "Apple Orange Mango" but i want as
Apple
Orange
Mango
JTable jt = new JTable( data, fields );
where 'fields' represents columns.
please help me out.

-Thanks & Regards,
Hamsa


Do I understand you correctly, if I say, currently you are getting this:


whereas what you want to achieve is this:


where x and y are some other values?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Hamsagayathri Palanisamy
Ranch Hand

Joined: Mar 10, 2008
Posts: 44
Originally posted by Maneesh Godbole:


Do I understand you correctly, if I say, currently you are getting this:


whereas what you want to achieve is this:


where x and y are some other values?





No Maneesh,i didnt mean that way. As for my code,I'm getting as follows


But what i want is



Hope now you got it.please help me out.

-Thanks & Regards,
Hamsa
satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
It would be better if you could post your executable code. You will get more response
Hamsagayathri Palanisamy
Ranch Hand

Joined: Mar 10, 2008
Posts: 44


for data[n][1] i'm getting values from resultset as "value1 value2 value3" in horizontal. i need to format that to vertical as

value1
value2
value3

for data[n][1] where 'n' may be any value.

-Thanks & Regards,
Hamsa
satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
Try this

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10175
    
    8

Originally posted by Hamsagayathri Palanisamy:
[CODE]... i need to format that to vertical as


The solution provided by Stuart Smith will exactly do what you want. Did you even try it out?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: next line in swings
 
Similar Threads
same key for diff values in HashMap
ADDING TWO XML FILES
Constructor of parent abstrat class not getting executed.
Adding contents of two XML's into one
Constructors