Dynamically change JTable header

Hi to all,
I was reading this topic regarding column spaning (Groupable Header) which was very helpful to what i wanted to do.
Although, i am facing a problem while trying to change the header value according to the value of a combo box.
I don't need to change the header value of the individual columns but the value of the groupable header.
Has anybody have tried something similar ?
thnx in advance.

Problem has been resolved.
I have modified the 'addColumnGroup(ColumnGroup g)' of the class 'GroupableTableHeader.java' in order to empty the ColumnGroup vector before adding a new group.

Similar Messages

  • Changing jtable header when moving down

    Hi,
    I would need changing Jtable header, when the cursor switches between lines
    How to do this ???
    Best Regards
    S.Ancelot

    1) You could create a second table header and replace the old one using scrollPane.setColumnHeaderView(...)
    2) Or, you could simply change the values in each TableColumn and then repaint the header.

  • OBIEE 10g AGO Function Dynamically Change the Heading

    I created columns in my rpd named Sales Previous Month, Sales 2 months ago and Sales 3 months ago using the AGO Function. This is working fine.
    My problem is when displaying these headings the users would like to see the Month Name instead of the Headings I created. For example if looking at a report for January the users would like to see:
    Sales Previous Month = December
    Sales 2 Months ago = November
    Sales 3 Months ago = October
    Is there any way to dynamically change the value of the column header to show the name of the month?

    Hi SriniVEERAVALLI,
    Thanks for the reply. I have found that I might haven't created the relationship between dimension and fact tables correctly.
    I initially created the foreign key relationship (instead of creating complex join) in physical diagram between the dimension and fact table. And the relationship type is hence greyed out.
    I have deleted the foreign key relationship in physical diagram. Then
    1. In physical diagram, create complex join between dimension and fact . The relationship is 'inner' and can't be changed.
    2. In Logical table diagram, create foreign key between dimension and fact . The relationship can be changed (inner, outer, etc).
    Is this the correct way?
    I tried these on two newly created dummy tables and it worked.

  • Merging of 2 Cells in WD ABAP ALV Header & Dynamically change the header

    Hello Experts,
    I have two main requirements with respect to WD ABAP - ALV report creation
    1) Two feilds in the  header of ALV GRID created in the WD ABAP screen must be merged as shown below(Month Column) ,
    |     January         |     February         |  
    |   Col 1 | Col2      |   Col 1 | Col2        |     
    2) The header value(Month) should dynamically change based on the current date.
    For Eg: If June 2011 is the current month , the ALV table should start from June 2011 and displayed till May 2012.
    Looking forward for your valuable inputs @ the earliest
    Regards,
    Sriram

    Hi Sriram,
    For merging..
    Pleaese go through this
    Merge of Cells in ALV table in ABAP webdynpro.
    ABAP WD: ALV merge cells
    For Header Change..
    How to set title/text for ALV table column header in WD ABAP
    Change column header in ALV to another DDIC Element type
    Change label of a column in ALV
    Cheers,
    Kris.

  • Dynamically change column heading without Dashboard Prompt

    Hi All,
    My requirement is change the column heading dynamically in a report. I have achieved this through setting the presentation variable to the dashboard prompt.
    I have 5 columns in the dashboard prompt. Out of these 5 columns, I want to use only 1 column as dashboard prompt.
    But still I want to dynamically change the column heading of the other 4 columns based on the only 1 column selected in the dashboard prompt.
    Is there anyway to achieve this?

    You need to have some logic to change other 4 columns based on 1 selected column.. where you want put that logic?
    BTW: Check these
    http://total-bi.com/2011/03/obiee-dynamic-column-headings/
    http://rampradeeppakalapati.blogspot.com/2012/02/dynamically-change-column-names-in.html
    If helps mark or also update back if you are thru with this.

  • Dynpro table -dynamically change table header name

    how to change table header name at runtime ?
    for instance, when i bind to a dataNode with this attribute:
    smsid, usrid, crdate, stdate,enddate
    change to
    message_id, user_id, create_date, start_date, end_date  during runtime.

    Hi yzme,
    To change the column header for each field you have to set the [Caption-Header] text value.
    Use this code inside "wdDoModifyView" method.
        //@@begin wdDoModifyView
         IWDCaption smsid_caption = (IWDCaption)view.getElement("smsid_header");
         smsid_caption.setText("message_id");
         IWDCaption usrid_caption = (IWDCaption)view.getElement("usrid_header");
         usrid_caption.setText("user_id");
         IWDCaption crdate_caption = (IWDCaption)view.getElement("crdate_header");
         crdate_caption.setText("create_date");
         IWDCaption stdate_caption = (IWDCaption)view.getElement("stdate_header");
         stdate_caption.setText("start_date");
         IWDCaption enddate_caption = (IWDCaption)view.getElement("enddate_header");
         enddate_caption.setText("end_date ");
            //@@end
    Regards,
    Mithu

  • Dynamically changing page heading

    Hi,
       I need to change my page heading dynamically how can i do that one.
    For example i have a view which contains a view container and four buttons like create, change... When i press a button the appropriate page heading should come.
    I am expecting to ur valuable answer.
    Regards...
    Arun.

    Hi Arun,
    As far as I know, you cannot change the page heading (if you are referring to the heading on the IE window) dynamically, as it is the name of your application.
    However, you can use a PageHeader UI Element (at the top in ur RootUIElementContainer) and bind the 'title' property to an attribute in your context. You can change this attribute, depending on any events that occur.
    Regards,
    Neha
    <i><b>PS:Reward of helpful</b></i>

  • 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.

  • How do i change the cursor on a jtable header when clicked for sorting?

    here is my question, how do i change the cursor on a jtable header when I click the header for sorting?
    I think it is suppose to be in the fragment of code where the header listener is implemented for sorting, but I'm not quite sure what is the exact component that holds everything so that i can change the cursor...
    below is what I've tried, but it doesn't seem to work... thank you
    public void addMouseListenerToHeaderInTable(JTable table) {
    final TableSorter sorter = this;
    final JTable tableView = table;
    tableView.setColumnSelectionAllowed(false);
    MouseAdapter listMouseListener = new
    MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    TableColumnModel columnModel =
    tableView.getColumnModel();
    int viewColumn =
    columnModel.getColumnIndexAtX(e.getX());
    int column =
    tableView.convertColumnIndexToModel
    (viewColumn);
    System.out.println("column = "+column);
    if (e.getClickCount() == 1 && column != -1) {
    System.out.println("Sorting ...");
    Cursor oldCursor =
    tableView.getRootPane().getCursor();
    System.out.println("oldCursor.getType()
    = "+oldCursor.getType());
    if (oldCursor.getType() !=
    Cursor.WAIT_CURSOR){
    JComponent parentPane =
    tableView.getRootPane();
    parentPane.getContentPane().setCursor
    (new Cursor(Cursor.WAIT_CURSOR));
    parentPane.setCursor(new Cursor
    (Cursor.WAIT_CURSOR));
    Cursor newCursor =
    parentPane.getCursor();
    System.out.println("newCursor.getType
    () = "+newCursor.getType());
    int shiftPressed = e.getModifiers(
    &InputEvent.SHIFT_MASK;
    boolean ascending = (shiftPressed == 0);
    //System.out.println("tableView.getRootPane()
    is "+tableView.getRootPane().getRootPane());
    sorter.sortByColumn(column, ascending);
    tableView.getRootPane().setCursor(new Cursor
    (Cursor.DEFAULT_CURSOR));
    //System.out.println("Done sorting");
    JTableHeader th = tableView.getTableHeader();
    th.addMouseListener(listMouseListener);
    }

    Hi,
    Try setting the cursor for the table header.
    table.getHeader().setCursor(Wait_Cursor);
    Bala.

  • Change column header dynamically at report run time

    how to use LOV In report column definition under column attributes for display..
    If it suceeded will it dynamicaly change header name at time of running report
    my requirement is actually to change column header dynamically at time of run report
    is it possible with above mentioned way?
    Apex 4.1, Oracle 11g, PL/SQL Gateway configuration
    Please help me on this
    Thanks

    Hi,
    by making use of specific report column templates and column template conditions you can change the headers dynamically.
    See this http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21674/ui_templt.htm#HTMDB25708 for more info.
    regards,
    Erik-jan

  • How can data change dynamically between jtable

    hi,
    in my database i have 3 tables:
    university, etablissement, department.
    in one frame i want to create 3 jnavigationbars and 3 jtables each one represents a table.
    i want when i navigate in the jtable of university data in etablisement and department will be dynamically changed.
    can anyone help me.
    thanks

    Hi,
    make sure that the university, etablissement and department tables are related in the database when creating the ADF BC model. Then create a hierarchy of university, etablissement and department. Create the first table from university VO, the second from etablissement VO which is below university in teh VO hierarchy and eventually create a table on departmentVO below the etablissementVo
    Synchronization is handled automtically
    Frank

  • Dynamically changing rows in JTable don't re-render themselves

    Hi all,
    I've created a customized JTable and component editors/renderers. I also created a class that dynamically inserts new rows into the JTable and can also move entire rows up and down in the JTable. Dynamic insertion is working fine, but I'm having a problem with dynamically moving the rows up and down. One of my implementations has a table with three columns, the first column is always a JLabel in a JPanel, the second column is a variety of custom editors, and the third column is a custom editor for a custom JButton. If I change the value of either column 2 or 3 and then try to change the rows position in the table (up/down), then the cell that was edited remains blank until I click anywhere in the row that has the blank cell. But if I edit either column 2 or 3 and then click on the cell for column 1 in the same row and dynamically change its position (up/down) then the cells are rendered correctly.
    I've tried numerous ways to fix this problem, including fireTableDataChanged() and repaint() on the component in the cell. Any help would be greatly appreciated,
    amlandis

    So I tried updating the UI, but that didn't fix it.
    Do you explictly call editor.stopCellEditing() ? That sets the new value to your model. I override all stop editing methods and make them call their cancelEditing counterparts... and during debugging I watch the model and it has the correct data. I think my table sometime gets stuck in an isEditing() == true state. But is there no way to say setEditing(false)?
    From the BasicTableUI below... it seems like if my table gets into its editing state, the cells won't be rendered.
        private void paintCell(Graphics g, Rectangle cellRect, int row, int column) {
            if (table.isEditing() && table.getEditingRow()==row &&
                                     table.getEditingColumn()==column) {
                Component component = table.getEditorComponent();
             component.setBounds(cellRect);
                component.validate();
            else {
                TableCellRenderer renderer = table.getCellRenderer(row, column);
                Component component = table.prepareRenderer(renderer, row, column);
                rendererPane.paintComponent(g, component, table, cellRect.x, cellRect.y,
                                            cellRect.width, cellRect.height, true);
        }

  • Dynamically resize JTable cell to fit a JList

    Hi!
    I've been banging my head trying to add some dynamic behavior to a TableCellEditor. In short I'm trying trying to make it resize the height of the current row (the one it is in) to reflect the changes made to the JList used to let the user edit the cells value (which is a list of items).
    I've come across some threads dealing with the problem of resizing a cell to fit its content. This however is usually only done once (in the 'getTableCellEditorComponent' function) and so only provides half the answer. Also, since the editor is only active during cell editing I've been trying to make it revert to the old cell height after the editing is done.
    So far I have not come up with any decent solution to this problem and was hoping someone out there might have an idea or have read something similar and can point me to something helpful... anyone?
    Cheers!
    Teo

    The Swing tutorial on[url http://java.sun.com/docs/books/tutorial/uiswing/components/table.html]How to Use Tables shows how to dynamically change the size to Table Columns.
    If you need help calculating the acutal size then try searching the forum. Using keywords "resize jtable column" (keywords I took directly from your topic title) I found some promising postings.

  • Dynamically changing JTableHeader.

    Hi,
    i want to provide the user with the functionality to change the header of a table at run time(say, by clicking on it). Is there any way to do it?Can the header be changed and displayed dynamically??
    bye.

    hi,
    First u should set cell renderer to u r table column.then u can change header text,bgcolor etc.i provided code snippet.hope it helps.pl. let me know whether u coluld succeed.
    cheers,
    mo
    TableColumn column[] = new TableColumn[table.getColumnCount()];
    for(int i = 0; i < table.getColumnCount(); i ++){
    tcm.getColumn(i).setHeaderRenderer(new MyHeaderRenderer());
    public class MyHeaderRenderer extends JLabel implements TableCellRenderer {
    public Component getTableCellRendererComponent(JTable table,
    Object value, boolean isSelected, boolean hasFocus, int row,
    int column) {     
                        String val=value.toString();
                        setText(val);
                        //setToolTipText(val);
                        setFont(new Font("Dialog",Font.BOLD,12));
                        //setBorder(BorderFactory.createLineBorder(Color.gray,1));
                        setBorder(BorderFactory.createEtchedBorder());
                        setHorizontalAlignment(SwingConstants.CENTER);
                        setOpaque(true);
                   //if(isSelected)               
                        //setBackground(table.getSelectionBackground());               
                   // else
                        // setBackground(Color.white);
                   return this;
    }

  • Multiple Icon on Jtable header

    Hi All:
    Any one had used multiple icons on JTable header ? According to the user's clicking positon under one column, one of these icons should change such as changing from sorting up arrows to sorting down arrows.
    I got the mouse clicking position on the header and column, then depend on the location, I wanted to perfrom different things. But I have not figured out if I should call header renderer to perform the repaint or not ? If I use JTable header render, how should I confine the one column that change should happen? I don't want to have all columns repainted. If I treat each column indivisually, should I reconstruct the JTable ? I used SortableTableModel to create the JTable.
    Any help is appreciated.
    Regards

    Here's the idea. I didn't test thisclass JComponentCellRenderer extends JButton implements TableCellRenderer {
        public JComponentCellRenderer (ImageIcon ii) { super("",ii); }
        public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {
            setText(value.toString());
            return this;
    }and thentblChanges.getColumnModel().getColumn(0).setHeaderRenderer(new JComponentCellRenderer(new ImageIcon( "CheckBoxHeaderImage" )));

Maybe you are looking for