datagrid


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 14 of 14

Thread: datagrid

Hybrid View

  1. #1
    Join Date
    Feb 2007
    Posts
    60

    datagrid

    peace..
    hey everybody
    I m workin on a simple application with JAVA..nd I need to make an interface on which I v got to put some sql query results..I need some component like datagrid in VB..but I still don t find a free one..(just commercial)
    are there some free component for that on swing or a tutoriel how to use them?
    thanks

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    Have you looked at the JTable Class from the JDK?

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    What about building a simple HTML table?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  4. #4
    Join Date
    Feb 2007
    Posts
    60
    Well..it s not a web application so I didnt think about using HTML tables...
    but I m gonna try fisrt with the Jtabel component..
    thanks for help

  5. #5
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Frankly, I've never heard of an application which uses Java that isn't a web application.

    Anyway, let us know how it turns out.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  6. #6
    Join Date
    Feb 2007
    Posts
    60
    Well..I m just beginner with java ..I mean that i m just trying to use a simple application with swing s component nd connect it with a datbase....
    anyway thx for help!!!

  7. #7
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Do you have it connecting with your database? (What database are you using?)

    As far as this goes
    Quote Originally Posted by peace_comp
    I need some component like datagrid in VB..but I still don t find a free one..(just commercial)
    Have a look at this.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  8. #8
    Join Date
    Nov 2007
    Posts
    3
    maybe you can try jxcell,a java spreadsheet component
    http://www.jxcell.net

  9. #9
    Join Date
    Feb 2007
    Posts
    60
    thaks for the link..
    I m using mysql ...

  10. #10
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Are you any further ahead than you were when you first posted your question?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  11. #11
    Join Date
    Feb 2007
    Posts
    60
    back...
    well i used a simple JTable .. like the following code :
    try { Vector data=new Vector ();
    Vector col=new Vector ();

    stat=con.createStatement();
    String sql3="select * from name_table;
    res=stat.executeQuery(sql3);
    rsmd = res.getMetaData();
    int nbr_colonne =rsmd.getColumnCount();
    for (int i = 1; i <= nbr_colonne; i++) {
    col.addElement(rsmd.getColumnName(i));
    }
    while (res.next())
    {

    Vector row = new Vector();
    for (int i = 1; i <=nbr_colonne ; i++)
    {
    row.addElement(res.getObject(i));
    }

    data.addElement(row);
    }
    JTable tab=new JTable(v1,v2);
    JScrollPane scr = new JScrollPane(tab);
    ....



    }catch(Exception ex) {
    JOptionPane.showMessageDialog(null, "Erreur"+ex, "Warning", JOptionPane.ERROR_MESSAGE);

    }
    }
    **********************************************************
    now the problem is how to refresh the JTable... if new data is added it must be displayed at the JTable//??

  12. #12
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    Take a look at this discussion, using methods for your TableModel:

    http://www.programmersheaven.com/mb/...adMessage.aspx

  13. #13
    Join Date
    Feb 2007
    Posts
    60
    thx.
    well I have never use a TableModel .. so i don t know if it s already defined on a package or should I implemets the code ..
    for example ..i saw in many tuto that they use directly the DefaultTabelModel..but when I try to use it:
    DefaultTableModel mytab=new DefaultTableModel (v1,v2);// where v1 nd v2 are 2 Vectors..
    it gives error because the constructor is not defined !!
    so as I m new with java .. I don t really know how to implement it..I tied some code but it doesnt work..
    plz if some one could tell me the goood way to do it ..or a tuto for that..
    thanks

  14. #14
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    your table's getTableModel() method will return the tablemodel object which the JTable creates as a default if you do not tell the table to use another model.

    The defaulttablemodel has implemented TableEvent listeners and table events ...

    Take a look at the tutorial, now, knowing that you do not separately construct the DefaultTableModel.

Similar Threads

  1. Replies: 7
    Last Post: 07-09-2006, 02:56 AM
  2. Replies: 0
    Last Post: 09-02-2005, 08:28 PM
  3. Replies: 0
    Last Post: 06-05-2003, 10:30 PM
  4. Is there guidelines for proper use of DataGrid
    By Thomas Eyde in forum .NET
    Replies: 8
    Last Post: 08-01-2002, 07:43 PM
  5. Threading and the .NET Datagrid
    By McCleud in forum .NET
    Replies: 2
    Last Post: 08-01-2002, 11:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center