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
17 1189
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
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
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
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
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
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
'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
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
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
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
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
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
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
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
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: -
String columnFromDB= "apple orange strawberry";
-
columnFromDB= columnFromDB.replaceAll(" ", "<br>");
-
columnFromDB= "<html>"+columnFromDB+"</html>";
-
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
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: -
String columnFromDB= "apple orange strawberry";
-
columnFromDB= columnFromDB.replaceAll(" ", "<br>");
-
columnFromDB= "<html>"+columnFromDB+"</html>";
-
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
Thanks Jos..
-Thanks & Regards,
Hamsa
I was starting to fear that this thread was starting to obey the law of long threads.
Sign in to post your reply or Sign up for a free account.
Similar topics
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....
...
|
by: maverick19 |
last post by:
Hi could any one give some references for pagination with caching in swings
|
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 ,...
|
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...
|
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...
|
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...
|
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 ={
...
|
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...
|
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
|
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,...
|
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$) {
}
...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
| |