Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

JTable expert

  Asked By: Chisisi    Date: Jan 13    Category: Java    Views: 1150
  

i have developed a client applet for RMI
server,client gets vector of vectors from server. here
is the code

serverName =
java.net.Inet4Address.getLocalHost().getHostName();
PendingServices myServerObject =
(PendingServices) Naming.lookup(
serviceURL);
Vector vector =
myServerObject.getStockOrder();

/////// setting col names
Vector columnNames = new Vector();

columnNames.add("Action");
columnNames.add("Symbol");
columnNames.add("Quantity");
columnNames.add("Rate");
columnNames.add("Client Number");

DefaultTableModel dtm = new DefaultTableModel(vector,
columnNames);
JTable table = new JTable(dtm);
table.setEnabled(false);
table.setPreferredSize(new Dimension(100,
100));
JScrollPane scrollPane = new
JScrollPane(table);
scrollPane.getViewport().add(table);
add(scrollPane);

now my this code gives an output of just first vector
in table in applet. i wonder where are the others(as
DefaultTableModel takes vector of vectors as 1st arg).
any body can help and plz also tell me i how to
refresh this applet after 5 sec, i want this applet to
be auto refreshing after every 5 sec.

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Hooriya Khan     Answered On: Jan 13

I tried this... should work.. however, there seems to be something missing in
mine as wel...
let me work out this.. and i ll be back to u over the weekend.

 
Answer #2    Answered By: Adalia Fischer     Answered On: Jan 13

first u told me that there is some thing missing, have u made a change or u
added some thing? plz tell aniway i have tested the constructor of JTable which
takes vector  of vectors  to make a table  in a normal application without using
RMI, i faced same prob, but when i tried to display values of returned vector
using following code again in normal java application, i just saw result as i
expected without any error

for (int i = 0; i < vector.size(); i++) {
Vector sub = (Vector) vector.elementAt(i);
String[][] rowData = new String[sub.size()][5];
for (Enumeration e = sub.elements(); e.hasMoreElements(); ) {
rowData[i][j] = e.nextElement().toString();

................................................................
..................................................
.........................................
System.out.print(rowData[i][j] + " ");

so wat i did is simply extracted all the values from vector of vectors in 2-D
string and added in JTable. and shows the output to BOSS, (he never checks my
code :) ).so i get rid of trouble but i know this is not the way, thanks you
very much for giving my prob so much time but plz tel me or refer some easy
tutorial so that i can pick this mess.

 
Answer #3    Answered By: Tracy Myers     Answered On: Jan 13

Follow Sun tutorials or Java Series book from Sun for Swings.

 
Didn't find what you were looking for? Find more on JTable expert Or get search suggestion and latest updates.




Tagged: