How to change JTable column header text

How do you set the text in the JTable column headers? I know you can create a JTable specifying the text in an array:
<li>JTable(Object[][] rowData, Object[] columnNames)
But if you create the JTable specifying a TableModel,
<li>JTable(TableModel dm)
the header text defaults to "A", "B", "C", etc. I cannot figure out how to access the text in the header names so it can be changed to something useful. I know how to get the JTableHeader for the table, but it does not seem to have methods for actually setting header values.

I'm sure that model allows you to specify header values so you don't have to do so manually. I would be very surprised if it didn't override the default getColumnName() method to provide a reasonable names.She wasn't writing the class, but [url http://forums.oracle.com/forums/thread.jspa?messageID=9200751#9200751]outlining a design for me to implement. And, based on a previous comment I had made, I think she assumed I wanted the new design to look as much like the old as possible. There were no headers in the original design, which wasn't even a table.
Anyway, this works:
    final static String statisticsColumnNames[] = {
     "Type", "Count",
     "Red QE", "Green QE", "Blue QE", "Average QE",
     "Distance"
     qErrors = new QEBeanTableModel();
     JTable errorTable = new JTable(qErrors);
     TableColumnModel tcm = errorTable.getColumnModel();
     for (int col = 0; col < statisticsColumnNames.length; col++)
         tcm.getColumn(col).setHeaderValue(statisticsColumnNames[col]);
It looks like setHeaderValue() on the TableColumn is what I was looking for.Again, only used if you are dynamically changing the values at run time or you don't like the defaults provided by the Bean-aware model.I coded the above before I read your last post. The QEBeanTableModel is extremely specific to my program. I.e. I cannot imagine it being used anywhere else. Would it still be better to implement a getColumnName() within the table model? Looking at your [url http://www.camick.com/java/source/RowTableModel.java]RowTableModel.java source, I can see that it would not be difficult to do so.
Just decided to add the getColumnName() method. This whole sub-project is based on implementing a clean modern design (and learning about Java Beans). You've clearly stated twice that the method I have implemented is for dynamic header values only, which has already answered what I asked last paragraph.

Similar Messages

  • How to change "Details" column header text in AdvanceTable in AdvancedTable

    Hi All,
    i am using adavanced table in advanced table in OAF page to show the master and details ,
    my requirement is to change the header text of "Details" to some other meaning ful text .
    "Details' column will be visible at runtime ,no we cant change using process request ,
    Please help me on this ,its urgent
    Thanks & Regards
    Maheswara Raju

    You can get the handle to the Detail column by using the following:
    UINode d = outerTable.getDetail();
    However, as per OAF developer guide, it is not possible to change the label for the detail column. The devloper guide has the following:
    "In accordance with BLAF guidelines, the Detail column header text for the detail disclosure column and the Show/Hide link texts within the cells of the detail disclosure column can not be modified."
    Cheers,
    Saurabh

  • How to change the column header name dynamically based on sysdate

    Post Author: senthi_gokul
    CA Forum: WebIntelligence Reporting
    Dear All,
            i have designed some reports. i would like to change the column header dynamically based on sysdate. up to 24 months. can u help me, which add month function using the universe. i dont know if-then-else function is having the universe tool or not?

    Post Author: prasingh
    CA Forum: WebIntelligence Reporting
    Are you saying you are not able to create an object by value (select: statement) as sysdate and put it onto the headers of your report? You can use the add_months() function on the object to add the numbers of months you wish.
    Please let me knnow for more.. You can get in touch with me on [email protected] for quick reply. 

  • How to align ADF column header text

    Hi,
    I want to align ADF column header text to center regardless of whether the contents are text (which should be left aligned - done by the "formatType" attribute) or number (which should be right aligned - done by the "formatType" attribute) within a ADF table. the styleclass attributes also doesnt work. can anybody help me pl?
    Afi

    Hi Afi,
    use
    <af:column>
      <f:facet name="header">
        <af:panelHorizontal halign="center">
          <af:outputText value="#{bindings.DeptView.labels.Dname}"/>
        </af:panelHorizontal>
      </f:facet>
      <af:inputText value="#{row.Dname}"/>
    </af:column>instead of
    <af:column headerText="#{bindings.DeptView.labels.Dname}">
      <af:inputText value="#{row.Dname}"/>
    </af:column>Rado

  • How to change the column heading as the column changes

    dear memebrs,
    Take an example fo the table EMP. I need to create a report whose parameters are the table column names. so depending on the parameter(which is the column name) the report o/p changes.
    so i am dynamically selecting the table column names and getting the o/p. The problem is when the column changes the heading of it in the report o/p is not changing.
    we have to use format trigger for this, but i am not sure what code should we write in the format trigger of the boiler plate text of the column heading , such that it changes in accordance with the input which is nothing but column name.
    for ex: If i choose EMPNO as the parameter then my column heading should become Employee Number and so on.......
    your comments are welcomed
    regards
    sandeep

    you can use a formula column of datatype character and of any width needed instead of a boilerplate text for the heading name.
    In the formula column you can write code like below
    IF :P_COLUMN_NAME = EMPNO THEN
    return('Employee Number');
    ELSIF :P_COLUMN_NAME = SAL THEN
    return('Salary');
    END IF;
    where P_COLUMN_NAME the name of the column selected dynamically(i.e. the parameter).

  • How to change the column header in XsltListView webpart

    I have a XsltListView webpart. By default it displays the column name in the header. How do I change the header and give a friendly name? I am able to change the header, if I click on header and position the cursor at the right spot and change. But sometimes
    it does not work. Is there any property which I can set in order to change the header? Thanks in advance.
    ss

    Hi ss,
    Do you use SharePoint 2007 or 2010? And the XsltListView Web part only available in SharePoint 2010.
    If you are using SharePoint 2010, to customize the header for each column, please try the following step.
    Open list view in advanced mode in SharePoint Designer.
    Select a header you need to modify > Click Customize XSLT under Design tab on the ribbon > Click “Customize Item”.
    Then we can see <xsl:value-of select="$fieldtitle"/> has selected in Code view > Replace it with the text you want to display on the header.
    For example, I want to display the string “customized header” in the header, then replace
    <xsl:value-of select="$fieldtitle"/>
    With
    Customized header
    Save the page and test.
    Thanks & Regards,
    Emir Liu
    TechNet Subscriber Support in forum
    If you have any feedback on our support, please click here.
    Emir Liu
    TechNet Community Support

  • How to change the column header/channel name in an LVM file?

    Hi all,
    I made a VI (see attached JPG) that reads 2 voltages, but after calculations and other processes, ends up writing 6 columns of data to an LVM file (7 if you count the time).
    I have read in other posts that you can change the name of each signal so that the header of each column in the LVM files doesn't just say "untitled". However, as you see in my code, some signals are numeric (double) and one is a logic (1 or 0), so there is no way to edit the waveform properties of those signals (since they are not waveforms).
    Any ideas?
    Thanks!
    Attachments:
    untitled3.JPG ‏40 KB

    I would suggest looking at this existing post:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=175554
    I'll further mention that in the loop, for each channel you want to set the name of, the attribute name for the name of the channel is "NI_ChannelName".  The example in the thread above takes advantage of the fact that "NI_ChannelName" happens to be the first one defined.  I think it would be more robust to not bother reading the existing attributes, and instead just write the "NI_ChannelName" attribute with whatever new value you want.

  • Change column header text dynamically

    Hi,
    I have requirement to change the column header text dynamically in sap gui programming. but couldn't see straight forward way to achieve this.
    i tried following link but no success:
    [Re: Dynamic header text in table control - Dialog programming;
    Please share your suggestions if it can be acheived.
    Thanks,
    Rahul
    Edited by: Rahul Yadav on Oct 25, 2010 7:29 PM

    >
    anmol112 wrote:
    > Hi,
    >   So you can try 1 thing,
    > * Dont use default Column Headings
    > * Create I/O and choose ouput only and fix them in place of Column headings.
    > * pass the values to these I/O accordingly.
    >
    >
    > Thanks,
    > Anmol.
    How is this different from the previous post?
    Rob

  • Change Table control Column Header text dynamically

    Hi,
    I have an requirement to change table control column header text dynamically.
    i.e. I have about 10 columns in table control, out that need to change 5 columns header text. These header texts are stored in an internal table.
    I had looked into the below link but could not get exactly how to do it.
    Dynamic headers in table control
    Could you please tell me how to do that.
    Thanks in Advance.

    Hi Saba,
    What you will need to do is this.....
    1. First replace the column Header Text box by I/O Fields and name them accordingly.
    Say for example we will consider the same example which i had explained in the link.
    there in the column header we want the header to change when some dates and entered into two fields which are out of table control say
    Start Date: 01.01.2010 to End Date: 06.01.2010
    Now we want the header to look like this,
    Column  No.    -        1               2             3                  4               5               6
    Header label   -    01/FRI       02/SAT     03/SUN       04/MON     05/TUE      06/WED
    Header name -    SPOTS1   SPOTS2    SPOTS3      SPOTS4     SPOTS5    SPOTS6
    then you go as per the instructions in the link......
    Let me know if you need further help,
    Hope this solves your problem....
    Regards,
    Abhijit G. Borkar

  • Multi-colored JTable column heading?  How?

    Hi,
    I'm looking for a way to have JTable column heading text
    that can be displayed in multiple colors, so one string
    in one column header, might have each letter a different
    color.
    My application requires highlighting some of the letters
    of a word as red, while others are normal text (black).
    I've been using multi-line strings to simulate vertical
    naming for my column header, for example:
    PPP
    I I I
    N N N
    1 2 3
    for PIN1, PIN2, PIN3. The column data has a binary
    one or zero for each pin, grouped together in one JTable
    column. In my application, if there is an error, I want to
    color just the text representing, say PIN2 red and leave
    the surrounding PIN1 and PIN3 black.
    What approach should I take for doing this with JTable?
    Thanks!
    John Roberts
    [email protected]

    You should override the default cell renderer used by Java
    - JTable.getTableHeader().setDefaultRenderer(yourRenderer)
    Extend yourRenderer from JLabel and use HTML tags to change the color.
    - setText on JLabel with the HTML code like "<HTML> <BODY> <FONT COLOR="red"> A </FONT> <FONT COLOR="green"> B </FONT></BODY> </HTML>"

  • How to create column header text while downloading file

    How can we create column header text while downloading file using function GUI_DOWNLOAD(in SAP Release 4.6c) because there is no FIELDNAMES parameter in
    4.6c version.

    Hii,
      Check this sample code. I have called GUI_DOWNLOAD twice. Onetime to download header of table and next time data of table
    REPORT  z_file_download.
    DATA: w_name(90) TYPE c.
    DATA:
      BEGIN OF fs_flight,
        carrid   LIKE sflight-carrid,
        connid   LIKE sflight-connid,
        fldate   LIKE sflight-fldate,
        price    LIKE sflight-price,
        currency LIKE sflight-currency,
      END OF fs_flight.
    DATA:
      BEGIN OF fs_head,
        carrid(10) TYPE c,
        connid(10) TYPE c,
        fldate(10) TYPE c,
        price(10) TYPE c,
        curr(10) TYPE c,
      END OF fs_head.
    DATA:
      t_head LIKE
       TABLE OF
             fs_head.
    DATA:
      t_flight LIKE
         TABLE OF
               fs_flight.
    fs_head-carrid = 'CARRID'.
    fs_head-connid = 'CONNID'.
    fs_head-fldate = 'FLDATE'.
    fs_head-price  = 'PRICE'.
    fs_head-curr   = 'CURRENCY'.
    APPEND fs_head TO t_head.
    SELECT-OPTIONS:
      s_carrid FOR fs_flight-carrid.
    START-OF-SELECTION.
      SELECT carrid
             connid
             fldate
             price
             currency
        FROM sflight
        INTO TABLE t_flight
       WHERE carrid IN s_carrid.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
    *   BIN_FILESIZE                  =
        filename                      = 'D:\flight.xls'
       FILETYPE                      = 'ASC'
    *   APPEND                        = ' '
        WRITE_FIELD_SEPARATOR         = 'X'
    *   HEADER                        = '00'
    *   TRUNC_TRAILING_BLANKS         = ' '
    *   WRITE_LF                      = 'X'
    *   COL_SELECT                    = ' '
    *   COL_SELECT_MASK               = ' '
    *   DAT_MODE                      = ' '
    *   CONFIRM_OVERWRITE             = ' '
    *   NO_AUTH_CHECK                 = ' '
    *   CODEPAGE                      = ' '
    *   IGNORE_CERR                   = ABAP_TRUE
    *   REPLACEMENT                   = '#'
    *   WRITE_BOM                     = ' '
    * IMPORTING
    *   FILELENGTH                    =
      tables
        data_tab                      = t_head
    EXCEPTIONS
       FILE_WRITE_ERROR              = 1
       NO_BATCH                      = 2
       GUI_REFUSE_FILETRANSFER       = 3
       INVALID_TYPE                  = 4
       NO_AUTHORITY                  = 5
       UNKNOWN_ERROR                 = 6
       HEADER_NOT_ALLOWED            = 7
       SEPARATOR_NOT_ALLOWED         = 8
       FILESIZE_NOT_ALLOWED          = 9
       HEADER_TOO_LONG               = 10
       DP_ERROR_CREATE               = 11
       DP_ERROR_SEND                 = 12
       DP_ERROR_WRITE                = 13
       UNKNOWN_DP_ERROR              = 14
       ACCESS_DENIED                 = 15
       DP_OUT_OF_MEMORY              = 16
       DISK_FULL                     = 17
       DP_TIMEOUT                    = 18
       FILE_NOT_FOUND                = 19
       DATAPROVIDER_EXCEPTION        = 20
       CONTROL_FLUSH_ERROR           = 21
       OTHERS                        = 22
    IF sy-subrc NE 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = 'D:\flight.xls'
          filetype                = 'ASC'
          append                  = 'X'
          write_field_separator   = 'X'
        TABLES
          data_tab                = t_flight
        EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 6
          header_not_allowed      = 7
          separator_not_allowed   = 8
          filesize_not_allowed    = 9
          header_too_long         = 10
          dp_error_create         = 11
          dp_error_send           = 12
          dp_error_write          = 13
          unknown_dp_error        = 14
          access_denied           = 15
          dp_out_of_memory        = 16
          disk_full               = 17
          dp_timeout              = 18
          file_not_found          = 19
          dataprovider_exception  = 20
          control_flush_error     = 21
          OTHERS                  = 22.
      IF sy-subrc EQ 0.
        MESSAGE 'Download successful' TYPE 'I'.
      ENDIF.
      IF sy-subrc NE 0.
    *  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Regards
    Abhijeet

  • Wrapping table column header text

    Hi
    I want my jTable column header texts to be wrapped automatically when the text does not fit in the width of the column. Any one help me?
    thanks
    mortoza

    Hi
    Thanks for your good advise. I have checked the site and found double line header of table. BUT, those lines are static i.e. not wrapping rather fixed. I want it to be wrapped automatically when the width is smaller than the required width to display in on single line. Can anyone help?
    Mortoza

  • Changing generic column heading

    Hi ,
    How to change the column heading for generic types of columns ?
    Means i want to make it all caps but its in the form of Initcap by default also the column heading are disabled for generic types of columns .
    Any idea ?
    Thanks & Regards,
    Rosy...

    See Vikas if u create a report based on generic columns where the report region returns column headings on that occassion u are not seem to get the column headers editable mode rather it is in disabled fashion with Col1,col2,col3 like that but i want to make all the Headings that is going to be returned in CAPITAL rather what the HTMLDB engine returning by default as InitCap .
    Is there any way to make those caps ....
    Hope this pic helps you to understand.
    http://tinypic.com/jutrah.jpg
    Cheers,
    ROSY

  • (simple q) how do I change the font in a JTable column header?  thanks

    how do I change the font in a JTable column header?
    thanks

    JTableHeader header = yourTable.getTableHeader();
    // Set to serif, bold, size 12...
    header.setFont( new java.awt.Font( "serif", 1, 12 ) );
    // you can set others like color and border, too.
    header.setBackground(Color.white);
    header.setBorder( new EmptyBorder(15,2,15,2) );

  • How can i  change the column label text in a alv table display

    how can i change the column label text in a alv table display??
    A similar kinda of question was posted previuosly where the requirement was the label text was needed and following below code was given as solution :
    <i>*  declare column, settings, header object
    DATA: lr_column TYPE REF TO cl_salv_wd_column.
    DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings.
    DATA: lr_column_header type ref to CL_SALV_WD_COLUMN_HEADER.
    get column by specifying column name.
    lr_column = lr_column_settings->get_column( 'COLUMN_NAME1' ).
    set Header Text as null
    lr_column_header = lr_column->get_header( ).
    lr_column_header->set_text( ' ' ).</i>
    My specific requirement is i have an input field on the screen and i want reflect that value as the column label for one of the column in the alv table. I have used he above code with slight modification in the MODIFYVIEW method of the view since it is a process after input. The component gets activated without any errors but while run time i get an error stating
    <i>"The following error text was processed in the system CDV : Access via 'NULL' object reference not possible."</i>
    i have checked in debugging and the error occured at the statement :
    <i>lr_column = lr_column_settings->get_column( 'CURRENT_YEAR' ).</i>Please can you provide me an alternative for my requirement or correct me if i have done it wrong.
    Thanks,
    Suri

    I found it myself how to do it. The error says that it is not able to find the reference object i.e  it is asking us to refer to the table. The following piece of code will solve this problem. Have to implement this in WDDOMODIFYVIEW method of the view. This thing works comrades enjoy...
      DATA : lr_cmp_usage TYPE REF TO if_wd_component_usage,
             lr_if_controller  TYPE REF TO iwci_salv_wd_table,
             lr_cmdl   TYPE REF TO cl_salv_wd_config_table,
             lr_col    TYPE REF TO cl_salv_wd_column.
      DATA : node_year  TYPE REF TO if_wd_context_node,
             elem_year  TYPE REF TO if_wd_context_element,
             stru_year  TYPE if_alv_layout=>element_importing,
             item_year  LIKE stru_year-i_current_year,
             lf_string    TYPE char(x),
      DATA: lr_column TYPE REF TO cl_salv_wd_column.
      DATA: lr_column_header TYPE REF TO cl_salv_wd_column_header.
      DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings.
    Get the entered value from the input field of the screen
    node_year  = wd_context->get_child_node( name = 'IMPORTING_NODE' ).
    elem_year  = node_year->get_element( ).
      elem_year->get_attribute(
       EXPORTING
        name = 'IMPORT_NODE-PARAMETER'
       IMPORTING
        value = L_IMPORT_PARAM ).
      WRITE L_IMPORT_PARAM TO lf_string.
    Get the reference of the table
      lr_cmp_usage  =  wd_this->wd_cpuse_alv( ).
      IF lr_cmp_usage->has_active_component( ) IS INITIAL.
        lr_cmp_usage->create_component( ).
      ENDIF.
      lr_if_controller  = wd_this->wd_cpifc_alv( ).
      lr_column_settings = lr_if_controller->get_model( ).
    get column by specifying column name.
      IF lr_column_settings IS BOUND.
        lr_column = lr_column_settings->get_column( 'COLUMN_NAME').
    set Header Text as null
        lr_column_header = lr_column->get_header( ).
        lr_column_header->set_text( lf_string ).
    endif.

Maybe you are looking for

  • Solaris 8 wrong patches?

    Hi, there are 2 patches that don't install on my system : 118097-05 SunOS 5.8: bug fixes for cdrw 1.1 115951-03 Netra ct OBP update for SUNW,UltraSPARC-IIi-Netract For sure it's because the concerning packages are not installed. But why am I offered

  • Planner provisioning for user groups lost in Shared services

    Hi All, Everything was fine. All of a sudden, no users were able to login in to planning. On investigation it was found that all the planner/planning provision to the groups is lost in the shared services. Digged into log for a while and couldnt find

  • Need a new tutorial

    Hello out there, I am looking for a Dreamweaver tutorial that DOES NOT have pages/templates etc already set up in the lesson. I am trying to learn to build a page COMPLETELY from scratch. The online lessons all start with pre made pages. I want to le

  • New Macbook Air - display issues after waking from sleep

    I have a 1 day old Macbook Air 13" (2013) --- when I wake the machine from sleep, the display shows horizontal / vertical bands for a couple of seconds before clearing up to show the desktop. Please see attached picture. This doesn't happen 100% of t

  • Mail7.1 Group preferences don't work

    I have the preference to show all addreeses in a group UNCHECKED but when I send an email to a group all addresses are shown. How can I stop this? Bill