Problem in updating first column header in JTable

hi
I am using JTable in my application. I want to change first column name of JTable every time when a JList is selected. I am using DefaultTableModel for JTable. I added first column in Constructor and another in a method. I have to edit only first column header. How can i do this???
I used this code but it is not working.
table.getColumnModel().getColumn(0).setHeaderValue("Name of column");
table.getTableHeader().resizeAndRepaint();
Your help will be appreciated.
Thanks in advance
Sonal

table.getColumnModel().getColumn(0).setHeaderValue("Name of column");
table.getTableHeader().repaint();Works for me so post a SSCCE ( http://www.sscce.org/ ) that shows the problem.

Similar Messages

  • Retarded Column Heading of JTable

    I have a JTable where I allow automatic resizing of the columns because the user may choose between things of varying lengths to add to the table from a list. I have disabled reordering and resizing in the Table Header. However, the first column heading, "Response Variable", always shows up as "Response.." until you select at least one item from the list. It is driving me crazy. Why won't the entire column name show up all the time, regardless of how many rows the table has?

    try setting the TableColumn minWidth to the minimum size of the column heading. use the method setMinWidth(int minWidth) located in the TableColumn class. This should fix the problem. Let me know

  • Problem in displaying Column Heading using JTable

    I am using JTable component in my applet. I am trying to retrieve records from a database and want to display the same in the table using JTable component. In that procees my data is shown in the table but I am not able to display the column heading.
    Please suggest.

    you could user JScrollPane to show the column's head.
    if you don't want to use JScrollPane ,you should use the getTableHeader() method and add the header into the pane

  • Problem in Adding two buttons under same column header (in JTable)

    Hi,
    I have a JTable and to a particular column i want to add two buttons.
    Here the two buttons should be under the same column header and i need to add listners to these.
    Any idea how to do this?
    Thanks & regards
    Neel

    Of course as your header is drawn by a renderer, the buttons don't actually work, but you can listen for mouse clicks within the area of the header and see which button the mouse position was over.
    See the Java Table Sorter Demo code for how to add a mouse listener to the header...
    http://java.sun.com/docs/books/tutorial/uiswing/components/example-1dot4/index.html#TableSorterDemo
    ....and from there you should be able to determine where in the component the click occured by using the getX() and getY() methods of the MouseEvent to determine which button in the renderer component was clicked. Use something like Rectangle.contains() to match the click location against the buttons.

  • Problem at update blob columns.

    Hi,i have a table like this.
    create table customer
    (id number,
    photo blob,
    sign blob,
    pass_view blob);
    I have a form based to this table (at 9i) which has 3 image item.
    By using webutil i read image files to this items and after commit i stored them to database.There is no problem up to this time,inserting data to database seems correct.
    Now i want to update an imge from database and I open form again and execute query.All 3 images was seen.I changed 3rd pass_view image again by reading another image file from file system.After commit and execute_query again i understood that photo column is now having new pass_view image and pass_view column is null.
    In trying different loading to different images,i have problems again.
    Only if i read 3 images from 3 files to image items again,i have no problem in updating.
    Is there a problem in having 3 blob columns in a table?

    I have the problem even with 2 images (2 BLOB fields in table).
    Forms application updates the first image if you replace only the second image. If you replace both images everything is correct.
    Honestly speaking I have this problem with 9.0.2 version and probably in couple weeks I'll test it on 9.0.4.
    Thanks
    Vitaliy

  • Problem while exporting ALV column header to excel sheet.

    Hi,
    I am able to export an ALV grid details to an excel sheet. But the ALV column headers when exported to excel sheet are getting truncated.
    For eg: if my column header in ALV grid is displayed as 'Material' then the column header in excel sheet is 'Mater' only. Remaining portion is getting truncated.
    How can I view the entire column header text?
    Kindly assist.
    Thanks.

    I have the same problem with you, when user export to excel. I fixed it by using
    w_layo-colwidth_optimize = 'X'. <<<<<<<<<<<<This
    perform generate_fcat_reftab
        using 'PRUEFLOS' 'T_INPUT' '' '' 'Inspection Lot' 0.
    form generate_fcat_reftab  using    p_fieldname
                                        p_tabname
                                        p_ref_tabname
                                        p_ref_fieldname
                                        p_output_text
                                        p_output_lenght.
      clear w_fcat.
      w_fcat-fieldname = p_fieldname.
      w_fcat-tabname   = p_tabname.
      w_fcat-ref_fieldname = p_ref_fieldname.
      w_fcat-ref_tabname = p_ref_tabname.
      w_fcat-seltext_s = p_output_text.
      w_fcat-seltext_m = p_output_text.
      w_fcat-seltext_l = p_output_text.
      w_fcat-outputlen = p_output_lenght.
      w_fcat-ddictxt = 'L'. <<<<<<<<<<<<<<<<<<This
      append w_fcat to t_fcat.
    endform.

  • How to fix the value of first column in the JTable in java swing for every

    Hi ,
    I have a swing page that have table panel in which there is a table of size 7x4 now when I click on the perticulat row then that row data will displayin the table like that the selected row become the second column in the new table and the fist column of this table will remain constant for all the entry but the second column update according to the roe which is selected .How it is possible .
    Thanks in Advace,
    anu

    One thing you can do is to prevent the user from editing that column and programatically supply the values of that column yourself.
    JTable table = new JTable() {
       public boolean isCellEditable(int row, int col) {
           if(col == 0) {
              return false;
           return super.isCellEditable(row, col);
    };This allows you to prevent the user from editing the column information so you can supply some sort of a default value for the column always
    ICE

  • How to display 2 lines in the same column header of jTable?

    Please could you help me to display 2 character lines in the same column header of a JTable?
    And how to make a fusion between to cells?
    Thank you very much

    In Swing, most components will accept text in the html format
    http://java.sun.com/docs/books/tutorial/uiswing/components/html.html
    You can then use <br> tags to make your header text multiline

  • Databinding Problem after Update (SQL Column renaming)

    I updated my JSC yesterday. Since then I cannot bind a datatable column to a renamed SQL Column. Thats very distracting. Is there any configuartion change to do or something else.
    Another thing: Is there any check by the IDE which shows me, which component exists in the pagebean and which in the JSP. I got a lot of error regarding not existing getter and setter in the pagebean.

    Hi Marc,
    Please explain what is the problem you are facing while trying to bind a datatable column to a renamed SQL column. Are you getting any error messages, if so what are they? What are you trying to do exactly? It would be helpful if you can give a detailed step by step procedure to reproduce the problem.
    Every component that exists in the JSP will exist in the page bean too. Please explain what exactly you did to get errors about getter and setter methods. Are you adding components to the JSP source or Pagebean source manually? Again a step by step description for reproducing the problem will enable us to provide answers to your questions.
    Cheers
    Giri

  • How to define Column Header text table control

    Hi All,
    I have to create a function in which user will pass Field Name, Field Description.
    I have to show that field description in Table Control Columns as Text for columns.
    Like if a user pass Material , PLant etc, then first column header text will be Material and so on and in rows it will show the data.
    One more thing, is it possible to define the technical attributes like length based on field passed through function.
    Please help me to find out the solution.
    Thanks
    Piyush Mathur

    Hi Piyush,
    here are the some components of the screen . you can change tehm at run time in your code.
    components: name,input,output,required,length,active,invisible,intensified,group1,group2...etc.
    at ruin time you modify these attributes..
    your requirement is to change the name attribute.
    regards,
    sateesh

  • Error when updating blob column

    Hello,
    im using the SQL-Developer and i have problems with updating blob columns.
    I'm getting the following error:
    UPDATE "MED400_INSTALL"."AMEDN_INSURANCE_TEMPL" SET WHERE ROWID = 'AAM6j5ABGAAAADpAAJ' AND ORA_ROWSCN = '26019698898'
    One error saving changes to table "MED400_INSTALL"."AMEDN_INSURANCE_TEMPL":
    Row 15: ORA-01410: Ungültige ROWID
    I'm updating different tables and different rows.
    This error is not shown in all cases. I can update some rows but not all off them.
    Is this a bug?
    TIA

    I made some further investigations and have some more results.
    - the problem does not occur all the time
    - the problem seems to occur in the following situation
    - User A: updates the blob-field using the sql developer menu and commits (-> success)
    - User B: updates the blob-field using the sql developer menu and tries to commit (-> error)
    - the error stays until User B does a rollback, after the rollback user B can update the blob-field! and user A gets the error.
    Here are some extracts of sql developer log. It shows that the same row can be updated in somes cases, in others cases you get an error. After a rollback the field can be updated successfully The rowid ist the same. ora_rowscn is different:
    UPDATE "AZUBI2"."AMEDN_INSURANCE_TEMPL" SET WHERE ROWID = 'AAc6TTACEAAAAHQAAC' AND ORA_ROWSCN = '26087686991'
    One error saving changes to table "AZUBI2"."AMEDN_INSURANCE_TEMPL":
    Row 1: ORA-01410: Ungültige ROWID
    Rollback Successful
    UPDATE "AZUBI2"."AMEDN_INSURANCE_TEMPL" SET WHERE ROWID = 'AAc6TTACEAAAAHQAAC' AND ORA_ROWSCN = '26087687075'
    Commit Successful
    I could offer a dump where you can possibly reproduce this issue. Where can I send or upload it.
    Best regards,
    zebadmin

  • Simulating one column using two columns in a JTable

    What I need to do is "join" the two first columns of a JTable...
    What do I mean by saying "join" ?
    I want to make dissapear the right border of the first column, and the same thing for the left border of the second column, also do both things for the column headers of that two columns.
    All that to simulate having one column when there's actually two differents columns.
    How can i do that ? Thanks !

    Make a TableModel that filters your original table model.
    See JTable.setModel.
    public class MergedColumnsTableModel extends javax.swing.table.AbstractTableModel
         javax.swing.TableModel model;
         int[] columnSpans;
          * Assume for simplicity that model does not change (no columns inserted/deleted).
         public MergedColumnsTableModel(javax.swing.TableModel model) {
              this.model = model;
              columnSpans = new int[model.getColumnCount()];
              for (int columnIndex = 0; columnIndex < columnSpans.length; ++columnIndex) {
                   columnSpans[columnIndex] = 1;
         public void merge2(int columnIndex) {
              int leftSpan = columnSpans[columnIndex];
              int rightSpan = columnSpans[columnIndex + leftSpan];
              columnSpans[columnIndex + leftSpan] = 0;
              columnSpans[columnIndex] += rightSpan;
         public int getRowCount() {
              return model.getRowCount();
         public int getColumnCount() {
              int n = 0;
              for (int i = 0; i < columnSpans.length; ++i) {
                   if (columnSpans[i] != 0) {
                        ++n;
              return n;
         public Object getValueAt(int row, int column) {
              int n = 0;
              for (int i = 0; i < columnSpans.length; ++i) {
                   if (columnSpans[i] != 0) {
                        if (n == column) { // We are at the column
                             return model.getValueAt(row, i);
                        ++n;
    }

  • Updating a column of a table

    Hi all
    I have a problem in updating one column in the target table(say table A) from a column in the source table (say table B).
    All the columns in table A has been populated. Just one column should be populated. My source is a SQL object that contains a complex sql query that returns three columns date_from, date_to and ID.
    In the table A, I have the same date_from and date_to and need to get the ID from the SQL object and set it to the corresponding ID in the table A.
    I tried many ways to update the table, but it I couldn't ;(
    I should read from a table and update it based on a look-up function mapped to the column I need to update.
    I want to map the ID colmn from table A to a look-up ext function that can get the column from the table B. However I don't know how to use the Data Services objects to just update 1 column. If you could give me a consequence of the DS objects to be update a table based on a look-up , I would be so grateful.
    Thanks.

    Your dataflow should look like this :
    1) Source = the SQL transform with date_from, date_to and ID as columns.
    2) Next add a query (copy all columns from schema in to schema out) and set date_from and date_to as keys. Also make sure column names exactly match the column names in your target table, if not rename them in this query.
    3) Add a Map_Operation transform that maps all "normal" operation codes to "update"
    4) Finally add your target table and in the properties/options set "use input keys" to yes (or checked).
    This will generate UPDATE statements for all columns used in the query with a WHERE clause based on the keys defined in the query (date_from, date_to).
    Ben.

  • How to add multiple columns to single column header

    hi,
    i wans to add two columns under a single column header in jtable how can i do this.

    By following some of these clever samples:
    http://www.crionics.com/products/opensource/faq/swing_ex/JTableExamples1.html
    Lots of different ideas on manipulating headers and columns there and on the proceeding pages.

  • JTable howTo: column header = first column??

    Hi,
    i have created a JTable and with the TableColumnModel i have defined column headers. I now would like to have the first column of my table looking the same way like the column headers.
    It shall look similar to what you have in Excel tables: A B C.... = Column headers and 1 2 3 ... = line numbers = first (not editable) column of the table.
    I already tried to write an own table renderer which sets the color equal to the color of the headers but it still looks not equal :-( And there is no TableRowModel, right?
    How can I achieve this appearance?
    Thanks!!!
    Robert

    Here is a simple example to get you started:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=624365

Maybe you are looking for