Aidan Cowley

Greenhorn
+ Follow
since Feb 18, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Aidan Cowley

Oh, just found out that this does NOT print to the Jtable:
Vector v = new Vector();
v.add("Aidan");
System.out.println(v);
DefaultTableModel defaultModel = new DefaultTableModel();
efaultModel.addColumn("Description", v);
22 years ago
Hey again,
I ran that code with a whole bunch of println's just to see if it works. Alas, the method seems fine; i get the desired output on the console. For some truly mind boggling reason, it refuses to output it to the Jtable on the GUI - only the column names!
Vector v = new Vector();
v = SQL.getDescription();
System.out.println(v);
Then I immediately output it as follows:
defaultModel.addColumn("Description", v);
I get the "Description" table header - thats it though.
Just out of last ditch thoughts, I don't have to declare the table visible or something?

Thanks a million for the help,
Aidan
22 years ago
Thanks Manfred,
I can see what your saying . But I tried what you suggested and it still doesn't work. Perhaps vectors aren't the best way to handle this?
Any other ideas?
Aidan
22 years ago
Hey all,
I have a serious problem with getting my Jtable to display. It only displays the column names - not the data. The data is being derived from a result set (JDBC) - I know that that, at least, is working fine.
The Jtable uses the DefaultTableModel, and is displayed inside an internal window of the application.
Heres the relevant code:
public class SQL_Statements
{
public Vector getDescription()
{
try
{
SQL = "SELECT Description FRO Job_In_Info";
query_results = s.executeQuery(SQL);
while(query_results.next())
{
v.add(query_results.getString(1));
}
}
catch(SQLException e)
{
System.err.println("SQL Exception: " + e);
System.exit(0);
}
return v;
}
//The getDescription code works fine , i.e. System.out.println(v.lastElement()); produces whats it's meant to produce!
....
....
The main code is here:
SQL_Statements SQL;
JInternalFrame in = new JInternalFrame();
//Internal window named IN
Container contentPane = in.getContentPane();
DefaultTableModel defaultModel = new DefaultTableModel();
defaultModel.addColumn("Description", SQL.getDescription());
//addColumn susposedly has the following parameters addColumn(object column name, vector data);
JTable table = new JTable(defaultModel);
JScrollPane scroller = new JScrollPane(table);
contentPane.add(scroller);
//Note: The program uses internal windows. Could that be part of the problem?

...
...
Thast all the Jtable relevant code. Any ideas why the column name but not the data are displaying?
22 years ago