How To Display Table Header in JTable

Hi,
I have a tree node that is a JTable. It displays the cells, but not the header or the left hand side of the table.
Here is my code ...
Anyone got any ideas?
public SimpleTree() {
super("Creating a Simple JTree");
WindowUtilities.setNativeLookAndFeel();
addWindowListener(new ExitListener());
Container content = getContentPane();
JTable table;
     String columnNames[] = { "OrderID", "CustomerID", "EmployeeID", "Order Date", "Shipped Date" };
     String dataValues[][] =
          { "34", "234", "67","12/02/2002", "16/04/2002" },
          { "-123", "43", "853","12/02/2002", "16/04/2002" },
          { "93", "89.2", "109","12/02/2002", "16/04/2002" },
          { "279", "9033", "3092","12/02/2002", "16/04/2002" }
     table = new JTable( dataValues, columnNames );
     table.setEnabled(true);
     table.isCellEditable(4,4);
     table.setShowHorizontalLines(true);
     table.setShowVerticalLines(true);     
     table.getTableHeader().setForeground(Color.black);
     table.getTableHeader().setBackground(Color.lightGray);
     table.getTableHeader().setReorderingAllowed(true);
     table.getTableHeader().resizeAndRepaint();
     JTableHeader header = table.getTableHeader();
header.setUpdateTableInRealTime(true);
header.setReorderingAllowed(true);
     Object[] hierarchy =
{ "Orders",
new Object[] { "Orders",
                              table},
new Object[] { "Prodcuts",
new Object[] { "",
table },
"Employees",
"Suppliers" };
     DefaultMutableTreeNode root = processHierarchy(hierarchy);
     JTree tree = new JTree(root);
     tree.putClientProperty("JTree.lineStyle", "Angled");
     tree.setCellRenderer(new MyTreeCellRenderer(table));
     tree.setCellEditor(new SimpleTreeCellEditor(table));
     tree.repaint();
     table.repaint();
     tree.setRowHeight(-2);      
     tree.setEditable(true);
     content.add(new JScrollPane(tree), BorderLayout.CENTER);
     setSize(275, 300);
setVisible(true);

The column header is a different component of the table component. You can get this component directly and place it wherever you want in a container, just get them from the JTable:JPanel aPanel = new JPanel( new BorderLayout() );
JTable myTable = xxx;
aPanel.add( myTable.getTableHeader() , BorderLayout.NORTH );
aPanel.add( myTable, BorderLayout.CENTER );

Similar Messages

  • How to display the header data on different position in alv report

    hi all,
    how to display the header data on different position in alv report.
    for example ,
    customer                                                   name
      xxxx                                                         xxxx
                     vendor        name     street 
                      xxxx         xxxx      xxxxx
    pls   help me .

    hi
    as per my understanding you need to trnasfer header internal table data  to pdf..
    please check the following links for internal table to pdf..
    Convertion of Internal table data to PDF
    This link is related to ur issue
    Re: how to insert the calling of the FM: OTF to PDF
    Thanks

  • How to display table in editable mode

    hi all,
    I have displayed data using table wizard.Now i want to perform insert and delete row operations in table.but its displaying table in non-editable mode.
    can anyone tell me, what should i do to display it in editable mode.
    Thanks.

    Hi Swati,
    Please refer the link,
    How to display Table Control in Active mode
    Regards,
    Hema.
    Reward points if it is useful.

  • How to remove table header

    my system need to display data, i will apply to display in JTable(one field is checkbox, one is the detail info.), but i don't hope user feel their data was displayed in a table.so i do following:
    private static final String colName[] = {
    tblMain.setShowHorizontalLines(false);
    tblMain.setShowVerticalLines(false);
    tblMain.setSelectionBackground(Color.white);
    but i still meet a problem on how to hide the table header. anyone,please help guide.
    thanks in advance.
    Susan

    so great ,camickr ,it's realized, thanks a lot

  • How to see table header

    hi,
    i have my jtable populated and filled, with my string[] to populate the header, but i can see the header!
    how to do it?
    thanx

    Add the table to a JScrollPane. The JScrollPane will display the header.

  • How to hide table header?

    I can hide the table header in metal look and feel.
    but not in solaris cde look and feel.
    How to do this.
    Thanks a lot!

    I haven't tried but: The table header is displayed in the column header of the enclosing scrollpane. When adding the table to the scrollpane it calls scrollPane.setColumnHeaderView(getTableHeader()). I guess you can remove it by calling scrollPane.remove( mytable.getTableHeader() ).

  • How to Fix Table Header of Analysis Web Item in BEx Web Template

    Hi,
    I am using an Analysis Web Item to display line item report in BEx Web Template. Is there any way to fix the table header of the like in Excel for better navigation?
    Thanks in advance.
    Regards,
    Joon

    Thank you all for your quick responses (I will award points once this is sorted)
    On the information you have supplied this has opened up yet another new part of WAD that I have not experienced ...TAGs
    Shubhranshu - I have done what you said but as I have never used tags I have just had a look around and found that I can insert Any Tag but not sure if I should be doing that.  If it is inert any tag , I chose FONT from the drop down and cbmAttributes defaulted into the custom tab for the class name but not sure what it wants in the Attributes and CSS Style tab, it won't accept what I am putting which is leading me to believe that I shouldn't be doing it that way.
    Venkat - thanks for the links they will prove very useful.  I've had a look and although they talk alot about the XHTML code for tags they don't actually say how you do it in the editor - I would like to produce one that way first and then see the code it generates for it.  I'm a bit apprehensive with changing the code direct as I don't want to mess anything up.
    Thanks again for your help

  • How to display table in smartforms

    hai
    I want to display the output in table.. how to set table.. I tried with the display framed framed patterns but its not working.. is that right method?? pls give suggestion

    Hi
    Yes,you can display the contents of the output using tables.
    Refer these links:
    Tables in Smartforms
    drawing a table in smartforms.
    passing tables in smartforms
    Drawing table in smartforms
    Creating Tables in Smartforms
    Regards,
    Sravanthi

  • How to display dynamic header title in the report?

    I have a req to display dynamic header title in the report.
    When a id is entered in the prompt text, it will display the user data based on that user_id.
    so similarly....the header title should vary each time when you select different user_id.
    How can we implement this?

    >
    Zack H wrote:
    > Lazaro,
    >
    > It depends on what you want displayed in the heading for each id.
    > Please elaborate.
    >
    > Thanks,
    > Zack H.
    Zack..I have several projects listed under several project id's...
    so when a user selects project id 00164 then it should display something like "Project document for Jon Doe"
    again when the user selects project id as 00192 then it should display something like "project document for Zimmerman"
    Did you get it??

  • How to display  table in jsp pages

    hi all ,
    i want to diaplay the table in jsp page...ie,if i click on some option then i need to get the table in jsp page
    wiil u plz help me
    thanks in advance
    chintu

    hi all..
    i didnt ask how to design table in jsp...i am asking how to diaplay the table with data already stored in database...i just want to retrive the values in table and display in jsp.....
    thanks in advance...
    chintu

  • How to hide table header for empty table

    Hi,
    I wanna to hide table header for all tables which doesn't contain any data in my Adobe form. How can I do this? Helpful answers will be rewarded .

    HI Aliaksandr,
    You can use javascript to do this dynamically.
    For example, i used Adobe Designer 7.1 to add a table to a subform.
    Now, i have the object hierchy as:
    Level 1 - form1
    Level 2 - form2
    Level 3 - Table1
               -->HeaderRow
                    --> Cell1
                    --> Cell2
               -->Row1
                    --> Cell1
                    --> Cell2
    Now, i sleect the Table1 element, and write the javascript which is executed on Initialization, as
    if(this.Row1.Cell1.rawValue == "")
    this.HeaderRow.presence = "hidden" ;
    This will check that if the first row is empty, it will hide the header from the layout.
    You can use something similar for your requirement.
    Hope this helps,
    Siddhartha Jain

  • How to display table data without  using ALV  and table element.

    Hi,
            Its possible to display table data without using ALV  and table element.
           Every time i am fetching data based on (customer,status) fields and displaying these data in my output using alv
           (every time i am fetching single row data ),
           But problem is alv occupying more space in the output , i want to display data part only i dont want field names,
           settings and header data etc..things.
          Give solution to  display data part..
    Regards,
    Rakhi.

    Hi,
    Does you mean that you need ALV without default Function Toolbar...? If this is the case, the easy solution would have been to use Table Element rather. But, if you need to use ALV only without Function Toolbar, you can do away with that as well.
    In that case, after calling GET_MODEL, you need to add few more lines of codes to achieve your goal. Those lines are --
      DATA LV_VALUE TYPE REF TO CL_SALV_WD_CONFIG_TABLE.
        LV_VALUE = LO_INTERFACECONTROLLER->GET_MODEL(
    * Standard Filter Function setting to FALSE
        LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_SORT_COMPLEX_ALLOWED( ABAP_FALSE ).
        LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_FILTER_COMPLEX_ALLOWED( ABAP_FALSE ).
        LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_FILTER_FILTERLINE_ALLOWED( ABAP_FALSE ).
        LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_DISPLAY_SETTINGS_ALLOWED( ABAP_FALSE ).
        LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_VIEW_LIST_ALLOWED( ABAP_FALSE ).
        LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_SORT_HEADERCLICK_ALLOWED( ABAP_FALSE ).
        LV_VALUE->IF_SALV_WD_STD_FUNCTIONS~SET_HIERARCHY_ALLOWED( ABAP_FALSE ).
    * Standard Filter Function setting to FALSE Ends
    Here as you can easily notice that LV_VALUE is instantiated on CL_SALV_WD_CONFIG_TABLE. Now, using this LV_VALUE, you set standard functions as False to dis-allow their display.
    Hope this answers your query.
    Thanks.
    Kumar Saurav.

  • How to display table range navigation bar at the bottom of the tr table i

    Hello,
    While I am using trinidad, I have to face a critical issue. Can I display table range navigation bar at the bottom of the <tr table> in Trinidad? and remove the range dropdown list, only show the "previous" and "next" link? The project is critical on the UI, this problem is very small but has to be fixed? Does anyone have any ideas&#65311;

    Difficult to do?  No.
    <ul id="bottom-nav"><li><a hef="whatever.php">whatever</a></li><li class="last"><a hef="whatever2.php">whatever2</a></li></ul>
    With this CSS -
    ul#bottom-nav {
         list-style-type:none;
         overflow:hidden;
         width:70%;
         margin:0 auto;
    ul#bottom-nav li {
         float:left;
         padding-right:10px;
         border-right:1px solid #FFF;
    ul#bottom-nav li.last {
         border:none;
    ul#bottom-nav a {
         /* your styles here */

  • How to display column header of a JTable in JScrollpane's RowHeader

    Can anyone tell me if it's possible to display the colum headers of a JTable which acts as the row headers of a JScrollpane object?
    If the answer is yes, could he/she point me to the right direction?
    Thanks,

    I'm guessing the answer is no because the column header is layed out horizontally and a row header is layed out vertically. But it should be easy enough to test:
    scrollPane.setRowHeaderView(table.getTableHeader());
    Its not hard to create your own row header. Search the forum using "+setrowheaderview +camickr" to find examples I've posted.

  • How to display images in a Jtable cell-Urgent

    Hay all,
    Can anybody tell me that can we display images to JTable' cell,If yes the how do we do that(with some code snippet)? Its very urgent .Plz reply as soon as possible.

    Here is an example
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    class SimpleTableExample extends JFrame
         private     JPanel  topPanel;
         private     JTable  table;
         private     JScrollPane scrollPane;
         public SimpleTableExample()
              setTitle( "Table With Image" );
              setSize( 300, 200 );
              setBackground( Color.gray );
              topPanel = new JPanel();
              topPanel.setLayout( new BorderLayout() );
              getContentPane().add( topPanel );
              // Create columns names
              String columnNames[] = { "Col1", "Col2", "Col3" };
              // Create some data
              Object data[][] =
                   { (ImageIcon) new ImageIcon("User.Gif"), (String) "100", (String)"101" },
                   { (String)"102", (String)"103", (String)"104" },
                   { (String)"105", (String)"106", (String)"107" },
                   { (String)"108", (String)"109", (String)"110" },
              // Create a new table instance
    DefaultTableModel model = new DefaultTableModel(data, columnNames);
              JTable table = new JTable( model )
                   public Class getColumnClass(int column)
                        return getValueAt(0, column).getClass();
              };          // Add the table to a scrolling pane
              scrollPane = new JScrollPane( table );
              topPanel.add( scrollPane, BorderLayout.CENTER );
         public static void main( String args[] )
              SimpleTableExample mainFrame     = new SimpleTableExample();
              mainFrame.setVisible( true );
    }

Maybe you are looking for

  • BuleTooth couldn't be instilled on Intel Mac

    Q:When installed BlueTooth on the Intel Mac.It'll have error on last step, then failed to install.So is the BlueTooth can be installed on Intel Mac?

  • No sound while watching videos

    I finally figured out how to sync video's to my ipod,but when I go to play them,there is no sound at all.My earbuds are completely in the ipod.The video's play there's just no sound.Do any of you have any possible solutions?

  • Report on Folder Items Based on Security

    I have an application to be build. A report is to be generated on the available items in the folder hierarchy of an content area. The user selects the folder in the parameter entry form and the report should display only those items to which he has a

  • INSPECTION LOT NUMBER

    WHEN I DONE GR  AGAINST  PURCHASE ORDER  INSPECTION LOT  NUMBER  IS NOT COME TO SERIAL KINDLY  GIVE TO ME  SUGGETION  WHAT IS THE MISSING I AM USING  STANDARD  NUMBER RANAGES  IN  GR INSPECTION 010000000000 TO019999999999

  • How to call custom OAFregion in custom workflow

    Hi, We have created a custom workflow and we want the OAF regions to be called in that workflow. where should we call the OAF regions in the custom workflow Regards, Krishna