• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

next line in swings

 
Hamsagayathri Palanisamy
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Hamsagayathri Palanisamy
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Hamsagayathri Palanisamy
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be better if you could post your executable code. You will get more response
 
Hamsagayathri Palanisamy
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this

 
Maneesh Godbole
Saloon Keeper
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic