volavy
asked on
jTable in JBuilder
Hi!
I am somewhat a beginner in java programming and I have a question concerning managing jTables in JBuilder (v6).
Question:
A have lets say three string variables (s1, s2, s3) and I "simply" want to add this strings in a iterative way into different rows i a jTable on a button click. Like this:
jTable1:
Kolumn-name1 Kolumn-name2 Kolumn-name1
s11 s21 s31
s12 s22 s32
...and so on ...
Could someone help me with this?
Regards
/Peter
I am somewhat a beginner in java programming and I have a question concerning managing jTables in JBuilder (v6).
Question:
A have lets say three string variables (s1, s2, s3) and I "simply" want to add this strings in a iterative way into different rows i a jTable on a button click. Like this:
jTable1:
Kolumn-name1 Kolumn-name2 Kolumn-name1
s11 s21 s31
s12 s22 s32
...and so on ...
Could someone help me with this?
Regards
/Peter
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Incidentally, you've double-posted the question. I wonder if you could ask Community Support to delete it? https://www.experts-exchange.com/Community_Support/
I'll put a note in the duplicate to answer here.
I'll put a note in the duplicate to answer here.
for my first recommendation:
add your JTable instance to the JScrollPane.
-gkern
add your JTable instance to the JScrollPane.
-gkern
ASKER
Thanks a lot
/Peter
/Peter
public class SetTable {
final static String[] strings = { "a","b","c","d","e","f" };
static int ROW_COUNT = 2;
static int COL_COUNT = 3;
public static void main(String[] args){
int stringIndex = 0;
for(int col = 0;col < COL_COUNT;col++){
for(int row = 0;row < ROW_COUNT;row++){
setValueAt(row,col,strings
stringIndex++;
}
}
}
static void setValueAt(int row,int col,Object o){
System.out.println("value at " + row + "," + col + " = " + (String)o);
}
}