CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 1999
    Location
    usa
    Posts
    33

    how to create a jtable header that takes up 2 lines ?

    how do i create a jtable header that takes up 2 lines ?

    such as below ?

    | Sex |
    | M | F |



    Thanks again


    http://members.xoom.com/lookads

  2. #2
    Join Date
    Sep 1999
    Location
    Madurai , TamilNadu , INDIA
    Posts
    1,024

    Re: how to create a jtable header that takes up 2 lines ?


  3. #3
    Join Date
    Oct 1999
    Location
    usa
    Posts
    33

    Re: how to create a jtable header that takes up 2 lines ?

    cannot compile the source code at
    http://www2.gol.com/users/tame/swing...Examples2.html
    because it imports user defined classes.

    so, how now ?

    http://members.xoom.com/lookads

  4. #4
    Join Date
    Sep 1999
    Location
    Madurai , TamilNadu , INDIA
    Posts
    1,024

    Re: how to create a jtable header that takes up 2 lines ?


    Which example you were trying to compile ?



  5. #5
    Join Date
    Oct 1999
    Location
    usa
    Posts
    33

    Re: how to create a jtable header that takes up 2 lines ?

    the example is this, as below. it could not compile :-

    http://www2.gol.com/users/tame/swing...erExample.java


    /* (swing1.1beta3)
    *
    * |-----------------------------------------------------|
    * | | Name | Language |
    * | |-----------------|--------------------------|
    * | SNo. | | | | Others |
    * | | 1 | 2 | Native |-----------------|
    * | | | | | 2 | 3 |
    * |-----------------------------------------------------|
    * | | | | | | |
    *
    */
    //package jp.gr.java_conf.tame.swing.examples;

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;

    import jp.gr.java_conf.tame.swing.table.*;

    /**
    * @version 1.0 11/09/98
    */
    public class GroupableHeaderExample extends JFrame {

    GroupableHeaderExample() {
    super( "Groupable Header Example" );

    DefaultTableModel dm = new DefaultTableModel();
    dm.setDataVector(new Object[][]{
    {"119","foo","bar","ja","ko","zh"},
    {"911","bar","foo","en","fr","pt"}},
    new Object[]{"SNo.","1","2","Native","2","3"});

    JTable table = new JTable( dm ) {
    protected JTableHeader createDefaultTableHeader() {
    return new GroupableTableHeader(columnModel);
    }
    };
    TableColumnModel cm = table.getColumnModel();
    ColumnGroup g_name = new ColumnGroup("Name");
    g_name.add(cm.getColumn(1));
    g_name.add(cm.getColumn(2));
    ColumnGroup g_lang = new ColumnGroup("Language");
    g_lang.add(cm.getColumn(3));
    ColumnGroup g_other = new ColumnGroup("Others");
    g_other.add(cm.getColumn(4));
    g_other.add(cm.getColumn(5));
    g_lang.add(g_other);
    GroupableTableHeader header = (GroupableTableHeader)table.getTableHeader();
    header.addColumnGroup(g_name);
    header.addColumnGroup(g_lang);
    JScrollPane scroll = new JScrollPane( table );
    getContentPane().add( scroll );
    setSize( 400, 120 );
    }

    public static void main(String[] args) {
    GroupableHeaderExample frame = new GroupableHeaderExample();
    frame.addWindowListener( new WindowAdapter() {
    public void windowClosing( WindowEvent e ) {
    System.exit(0);
    }
    });
    frame.setVisible(true);
    }
    }


    http://members.xoom.com/lookads

  6. #6
    Join Date
    Sep 1999
    Location
    Madurai , TamilNadu , INDIA
    Posts
    1,024

    Re: how to create a jtable header that takes up 2 lines ?


    What errors you are getting ? Did you download all the 4 files ????

    If not , download all the 4 files . If yes , try to compile those files like this..

    c:\> javac.exe GroupableHeaderExample.java ColumnGroup.java GroupableTableHeader.java GroupableTableHeaderUI.java

    Before you compile , comment all "package ... " code.
    I did compile those files in my machine. It's working fine.

    Poochi..




  7. #7
    Join Date
    Oct 1999
    Location
    usa
    Posts
    33

    Yes. You're right.

    Yes. It works. I did not know that i have to download all the files you specified.

    Previously, i only downloaded 1 file and tried to compile.

    Now, it works.

    Thanks a lot.

    http://members.xoom.com/lookads

  8. #8
    Join Date
    Sep 1999
    Location
    Madurai , TamilNadu , INDIA
    Posts
    1,024

    Re: Yes. You're right.


    :-)) you are welcome ..


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured