Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

Java Jtable Vector

Thread view: 
AlejandroArias - 16 Nov 2007 21:45 GMT
Saludos tengo un vector asi:

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"));

ESto es loq sifnifica los datos

       lblCodigoCD = new JLabel("Codigo");
       lblArtista = new JLabel("Artista");
       lblGenero = new JLabel("Genero");
       lblPrecio = new JLabel("Precio");

NEcesito mostrarlo en un 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));

Pero me dice que el tipo de ListadoCD no es strig, que debo hacer para
solucionar esto?
AlejandroArias - 16 Nov 2007 21:48 GMT
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/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.