ClassCastException

Status
Nicht offen für weitere Antworten.
G

Günter

Gast
Warum bekomme ich eine ClassCastException? Was muss anders sein?

Code:
		String hallo = "hallo";
		Vector gehtnicht = new Vector();
		gehtnicht.addElement(hallo);
		JTable table = new JTable(gehtnicht, gehtnicht);

Ich stehe vor nem Rätsel...
 
B

bygones

Gast
also meines erachtens wird nicht da die Excpeiton geworfen, du castest ja nirgends etwas zu einem Objekt....
 

Ebenius

Top Contributor
SDK Docu.
public JTable(Vector rowData, Vector columnNames)

Constructs a JTable to display the values in the Vector of Vectors, rowData, with column names, columnNames. The Vectors contained in rowData should contain the values for that row. In other words, the value of the cell at row 1, column 5 can be obtained with the following code:

((Vector)rowData.elementAt(1)).elementAt(5);

Parameters:
rowData - the data for the new table
columnNames - names of each column

Da eine Tabelle zwei-dimensional Daten darstellt, sollten deine values anders aussehen.
Bei Dir sollte also:
Code:
String hallo = "hallo"; 
Vector title = new Vector(); 
title.addElement(hallo);
Vector data = new Vector();
data.addElement(title);
JTable table = new JTable(data, title);
stehen.

Ebenius
 
Status
Nicht offen für weitere Antworten.

Ähnliche Java Themen

Neue Themen


Oben