473,385 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Swings

184 100+
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
Apr 1 '08 #1
17 1189
dmjpro
2,476 2GB
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

In Windows "\n" is not working?
If you want to make the "\n" independent then you can do ...
System.getProperty("line.separator");

Debasis Jana
Apr 1 '08 #2
r035198x
13,262 8TB
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
Try using an HTML break tag
Apr 1 '08 #3
JosAH
11,448 Expert 8TB
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
Do I understand you correctly? You have one row with three columns and you
want the transposed of it, i.e. three rows with one column each?

kind regards,

Jos
Apr 1 '08 #4
gaya3
184 100+
Do I understand you correctly? You have one row with three columns and you
want the transposed of it, i.e. three rows with one column each?

kind regards,

Jos

yes Jos,you have understood rite..
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
Apr 2 '08 #5
JosAH
11,448 Expert 8TB
But what do you want if you have n > 1 rows with three columns each? Do you
want n columns and just three rows?

kind regards,

Jos
Apr 2 '08 #6
gaya3
184 100+
But what do you want if you have n > 1 rows with three columns each? Do you
want n columns and just three rows?

kind regards,

Jos
'n' it denotes the number of rows in resultset... it varies..

-Thanks & Regards,
Hamsa
Apr 2 '08 #7
JosAH
11,448 Expert 8TB
'n' it denotes the number of rows in resultset... it varies..

-Thanks & Regards,
Hamsa
Yes, that's what I wrote but what is the answer to my question?

kind regards,

Jos
Apr 2 '08 #8
gaya3
184 100+
Yes, that's what I wrote but what is the answer to my question?

kind regards,

Jos

yes Jos, I need for n>1 with three columns..

-Thanks & Regards,
Hamsa
Apr 2 '08 #9
JosAH
11,448 Expert 8TB
yes Jos, I need for n>1 with three columns..

-Thanks & Regards,
Hamsa
That is not what I mean, suppose you have the following rows:

f1 f2 f3
f3 f5 f6

Dou you want a JTable as:

f1 f4
f2 f5
f3 f6

?

that is: if you have n rows with three columns each, do you want a JTable with
three rows having n columns?

kind regards,

Jos
Apr 2 '08 #10
gaya3
184 100+
That is not what I mean, suppose you have the following rows:

f1 f2 f3
f3 f5 f6

Dou you want a JTable as:

f1 f4
f2 f5
f3 f6

?

that is: if you have n rows with three columns each, do you want a JTable with
three rows having n columns?

kind regards,

Jos

jos, u dont confuse with transpose concept.
In one column in Jtable i'm having as follow

column 1 column2
c1 c2 c3 ....

what i need is

column 1
c1
c2
c3

now u got it? where i'm getting value for that column1 from resultSet

-Thanks & Regards
Hamsa
Apr 2 '08 #11
JosAH
11,448 Expert 8TB
jos, u dont confuse with transpose concept.
In one column in Jtable i'm having as follow

column 1 column2
c1 c2 c3 ....

what i need is

column 1
c1
c2
c3

now u got it? where i'm getting value for that column1 from resultSet

-Thanks & Regards
Hamsa
No I still don't get it; see my previous reply; show me how you want to display the
values f1, f2, ... f6
Those 6 values are two rows of three columns each in your database. How do
you want to display them in your JTable?

kind regards,

Jos
Apr 2 '08 #12
gaya3
184 100+
No I still don't get it; see my previous reply; show me how you want to display the
values f1, f2, ... f6
Those 6 values are two rows of three columns each in your database. How do
you want to display them in your JTable?

kind regards,

Jos

Jos, in my DB, i 'm having values like

create table order_table(order_num varchar(10),customer_name varchar(50) fruits varchar(100))

In the above table i'm having entry like {'111','AAAA','Apple Orange Mango'}

In front end, i;m executing the query as
"select fruits from order_table where ordernum=111".
From the resultSet i'm getting as

while(rs.next())
{
temp[i][0] = rs.getString(1); //here i'm getting as 'Apple orange Mango'
i++; i need as one by one(how to format it store in
array)
}


hope now u got it..

-Thanks & Regards,
Hamsa
Apr 2 '08 #13
JosAH
11,448 Expert 8TB
Jos, in my DB, i 'm having values like

create table order_table(order_num varchar(10),customer_name varchar(50) fruits varchar(100))

In the above table i'm having entry like {'111','AAAA','Apple Orange Mango'}

In front end, i;m executing the query as
"select fruits from order_table where ordernum=111".
From the resultSet i'm getting as

while(rs.next())
{
temp[i][0] = rs.getString(1); //here i'm getting as 'Apple orange Mango'
i++; i need as one by one(how to format it store in
array)
}


hope now u got it..

-Thanks & Regards,
Hamsa
Ah, ok, now I get it: you have three 'things' in one column of your database (that
is considered very ugly). You need to use some String methods like split() and
do a little programming; that's all. Use a List to store those columns and feed
that List to your single column JTable.

kind regards,

Jos
Apr 2 '08 #14
gaya3
184 100+
Ah, ok, now I get it: you have three 'things' in one column of your database (that
is considered very ugly). You need to use some String methods like split() and
do a little programming; that's all. Use a List to store those columns and feed
that List to your single column JTable.

kind regards,

Jos

Jos, i tried with String buffer concept as follows..
StringBuffer strbuff = new StringBuffer();
String fields[] = {"Fruits"};
while //loop
{
strbuff .append(String_from_resultset); ---------> I tokenized from the resultset
strbuff.append("/n");
data[i][1] = strbuff.toString();
}
JTable jtable = new JTable(data,fields);
still facing the same problem Jos..:-(

-Thanks & Regards,
Hamsa
Apr 2 '08 #15
JosAH
11,448 Expert 8TB
Jos, i tried with String buffer concept as follows..
StringBuffer strbuff = new StringBuffer();
String fields[] = {"Fruits"};
while //loop
{
strbuff .append(String_from_resultset); ---------> I tokenized from the resultset
strbuff.append("/n");
data[i][1] = strbuff.toString();
}
JTable jtable = new JTable(data,fields);
still facing the same problem Jos..:-(

-Thanks & Regards,
Hamsa
You have to read up on TableCellRenderers; the default one is just a 'rubber stamp'
of a JLabel and JLabels don't interpret '\n' characters at all so your three string
parts all end up on one line. A silly trick would be to feed the JLabel (actually
the renderer) an html string; something like this:

Expand|Select|Wrap|Line Numbers
  1. String columnFromDB= "apple orange strawberry";
  2. columnFromDB= columnFromDB.replaceAll(" ", "<br>");
  3. columnFromDB= "<html>"+columnFromDB+"</html>";
  4.  
This code snippet effectively turns this:

"apple orange strawberry"

into this:

"<html>apple<br>orange<br>strawberry</html>"

and it will be rendered as three lines but it will still be one single column value.

kind regards,

Jos
Apr 2 '08 #16
gaya3
184 100+
You have to read up on TableCellRenderers; the default one is just a 'rubber stamp'
of a JLabel and JLabels don't interpret '\n' characters at all so your three string
parts all end up on one line. A silly trick would be to feed the JLabel (actually
the renderer) an html string; something like this:

Expand|Select|Wrap|Line Numbers
  1. String columnFromDB= "apple orange strawberry";
  2. columnFromDB= columnFromDB.replaceAll(" ", "<br>");
  3. columnFromDB= "<html>"+columnFromDB+"</html>";
  4.  
This code snippet effectively turns this:

"apple orange strawberry"

into this:

"<html>apple<br>orange<br>strawberry</html>"

and it will be rendered as three lines but it will still be one single column value.

kind regards,

Jos

Thanks Jos..

-Thanks & Regards,
Hamsa
Apr 2 '08 #17
r035198x
13,262 8TB
Thanks Jos..

-Thanks & Regards,
Hamsa
I was starting to fear that this thread was starting to obey the law of long threads.
Apr 2 '08 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: navjyot | last post by:
Hi everybody I am using eclipse 3.1.0 version.I am new to it.Actually i want to run few screens which are made up in java swings in eclipse.So ,how can i run it.What run as option to choose.... ...
0
by: maverick19 | last post by:
Hi could any one give some references for pagination with caching in swings
1
by: manju1983 | last post by:
hello hi everyone, i am doing project using java swings now i have created a Jframe .that jframe contains 3 text fields and 2 jbuttons. now the problem is , when i press the submit button ,...
11
by: ravindarjobs | last post by:
hi friends, i have just moved from vba to java. i am quite new to java. but unexpectedly i was given a task to build a chart for a table stored in oracle database. we have to use only swings...
3
by: sumuka | last post by:
Hello, I'm doing a project in java using swings ,im able to create a panel and frame but i have a problem in event handling.I have added the MouseMotionListener but it's giving some error .Here i...
1
by: better | last post by:
I want to take help for the Table Handling in java and the Trees handling. I am not having any clues about it. I just downlad a cuple of of books on it but they does not explain these things but just...
1
by: gaya3 | last post by:
Hi, I have craeted JTable in Swings.I would like to make the contents in that JTable as "hyper link". I have generated JTable as follows. String fields = {"col1", "col2"}; String data ={ ...
1
by: swatiawasthy | last post by:
hi i am developing a gui in java swings and i am getting my database displayed in jtable... i have a textfield labeled CUSTID and my table also has its sec column as CUSTID (which is not a primary...
2
by: satyabhaskar | last post by:
hi all, i want to know the perfect example where we can use only awt or we can use only swings in the GUI programming... can any plz clear my doubt thanks
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.