Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: [ASK] how to make sorting jtable?

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default [ASK] how to make sorting jtable?

    i'm a newbie,
    I hope there is help in the same instance
    I really do not know and can not do it

    I have a table
    how to make sorting jtable??

    private void search(){

    DefaultTableModel tabModel = (DefaultTableModel) Tabel_Barang.getModel();
    tabModel.setRowCount(0);


    try{
    strSql = "";
    strSql = " SELECT kodebarang,category,merk,itembarang,type,satuan FROM masterbarang ";
    stmt=koneksi.createStatement();
    rslt=stmt.executeQuery(strSql);

    while(rslt.next()){
    String kodebarang=rslt.getString("kodebarang");
    String category=rslt.getString("category");
    String merks=rslt.getString("merk");
    String itembarang=rslt.getString("itembarang");
    String type=rslt.getString("type");
    String satuan=rslt.getString("satuan");

    Object[] data = {kodebarang,category,merks,itembarang,type,satuan} ;
    tabModel.addRow(data);
    AutofitTableColumns.autoResizeTable(Tabel_Barang, true);
    }


    }catch (SQLException ex) {
    Logger.getLogger(contoh.class.getName()).log(Level .SEVERE, null, ex);
    }

    }
    Attached Images Attached Images


  2. #2
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: [ASK] how to make sorting jtable?

    What happened when you've tried the various examples and tutorials, that can be found via google?

  3. #3
    Junior Member
    Join Date
    Sep 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [ASK] how to make sorting jtable?

    I've looked it up on google but I still do not understand, and I hope there is help in the same instance

  4. #4
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: [ASK] how to make sorting jtable?

    Post your SSCCE and ask specific questions, we wont do it for you.

  5. #5
    Junior Member
    Join Date
    Sep 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: [ASK] how to make sorting jtable?

    I want to do the sorting table by clicking on the header, then the data field can be order by asc or desc

Similar Threads

  1. How do i make My Jbutton Edit selected Row in Jtable
    By legend101z in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 7th, 2013, 04:59 PM
  2. JDBC and jTable (sorting)
    By PaulJ92 in forum JDBC & Databases
    Replies: 1
    Last Post: January 3rd, 2013, 07:41 PM
  3. Replies: 21
    Last Post: November 27th, 2012, 10:58 PM
  4. Sorting Formatted Numbers In JTable
    By aussiemcgr in forum Java Theory & Questions
    Replies: 1
    Last Post: August 10th, 2011, 09:40 PM
  5. Swing JTable sorting
    By chronoz13 in forum Algorithms & Recursion
    Replies: 2
    Last Post: January 30th, 2010, 08:51 AM