English
Hi I have this Vector
Vector ListadoCD = new Vector();
ListadoCD.addElement(new CD("R1", "50 Cent", "Rap", "20000"));
ListadoCD.addElement(new CD("P2", "Ricardo Arjona", "Pop",
"35000"));
ListadoCD.addElement(new CD("D3", "Antoine Clamaran","Dance",
"30000"));
ListadoCD.addElement(new CD("S5", "Victor Manuelle","Salsa",
"23000"));
I need show in a JTable
DefaultTableModel modelo = new DefaultTableModel();
JTable Tabla = new JTable(modelo);
BorderLayout borderLayout1 = new BorderLayout();
final JTable table = new JTable(ListadoCD, titulos);
table.setPreferredScrollableViewportSize(new
Dimension(500, 70));
But I have one error in
final JTable table = new JTable(ListadoCD, titulos); sometghing
with string format... :(
What can I do?
Curt Welch - 21 Nov 2007 15:30 GMT
> English
>
[quoted text clipped - 18 lines]
>
> final JTable table = new JTable(ListadoCD, titulos);
Why are you creating two JTables?
> table.setPreferredScrollableViewportSize(new
> Dimension(500, 70));
[quoted text clipped - 4 lines]
>
> What can I do?
You didn't show us what titulos was defined as or give us the actual error
message. Not much we can help you with if you don't give us the data we
need.
I believe it should be something like this:
Vector<String> titulos = new Vector<String>();
titulos.add("Column Label 1");
titulos.add("Column Label 2");
titulos.add("Column Label 3");
Is it?
I don't believe your Vector of CD objects is going to work unless CD is a
subclass of Vector. You need a Vector of Vectors:
Vector ListadoCD = new Vector();
ListadoCD.add(new Vector(
Arrays.asList("R1", "50 Cent", "Rap", "20000")));
ListadoCD.add(new Vector(
Arrays.asList("P2", "Ricardo Arjona", "Pop", "35000"")));

Signature
Curt Welch http://CurtWelch.Com/
curt@kcwc.com http://NewsReader.Com/