Freezing columns in JTable....  -  Need Suggestions!!!!!!!!!

Hai Friends,
i need suggestions for the following,
How to freeze the columns in swing JTable.?????????????
I need to freeze 3 columns in JTable... how it can be done?
eg: its like the option used in excel for freezing the panes. like that, i need to freeze the column in JTable. so that, it wont be scrolled while scrolling the records, it should also be done in colmns of jtable for horizontal scroll n row for vertical scroll. is this can be done in JTable. Can u pls help me out in this...?
Regards,
Ciya.

Did you actually try the code which was pointed out to you when you [url http://forum.java.sun.com/thread.jspa?threadID=701198]asked this question before? It does just what you want...

Similar Messages

  • Using Excel 2008 for a Mac in my laptop and part of toolbar has disappeared (windows, help, view, etc) and Need to to freeze column headings

    Using Excel 2008 for a Mac on my laptop
    Part of toolbar has disappeared (windows, help, view, etc) --- want to restore
    Need to freeze column headings but freezing option was not working prior to disappearance of tool bar

    Hi Alveretta,
    Thanks for posting in MSDN forum.
    This forum is for developers discussing developing issues on Windows platform. I suggest to get more effective response from
    Office for mac forum.
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or
    learn from your interaction with us.
    Thanks for your understanding.
    Best regards
    Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to freeze row and column in JTable

    Hi,
    I need to freeze first two rows and columns in a large JTable. I found ways to freeze either a row or a column, but not both at the same time.
    Can any of you help ?
    Found this code which allows freezing a col. Similar method can be used to freeze column
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JViewport;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.JTableHeader;
    import javax.swing.table.TableModel;
    public class FrozenTablePane extends JScrollPane{
    public FrozenTablePane(JTable table, int colsToFreeze){
    super(table);
    TableModel model = table.getModel();
    //create a frozen model
    TableModel frozenModel = new DefaultTableModel(
    model.getRowCount(),
    colsToFreeze);
    //populate the frozen model
    for (int i = 0; i < model.getRowCount(); i++) {
    for (int j = 0; j < colsToFreeze; j++) {
    String value = (String) model.getValueAt(i, j);
    frozenModel.setValueAt(value, i, j);
    //create frozen table
    JTable frozenTable = new JTable(frozenModel);
    //remove the frozen columns from the original table
    for (int j = 0; j < colsToFreeze; j++) {
    table.removeColumn(table.getColumnModel().getColumn(0));
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    //format the frozen table
    JTableHeader header = table.getTableHeader();
    frozenTable.setBackground(header.getBackground());
    frozenTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    frozenTable.setEnabled(false);
    //set frozen table as row header view
    JViewport viewport = new JViewport();
    viewport.setView(frozenTable);
    viewport.setPreferredSize(frozenTable.getPreferredSize());
    setRowHeaderView(viewport);
    setCorner(JScrollPane.UPPER_LEFT_CORNER, frozenTable.getTableHeader());
    }

    Hi,
    I need to freeze first two rows and columns in a large JTable. I found ways to freeze either a row or a column, but not both at the same time.
    Can any of you help ?
    Found this code which allows freezing a col. Similar method can be used to freeze column
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JViewport;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.JTableHeader;
    import javax.swing.table.TableModel;
    public class FrozenTablePane extends JScrollPane{
    public FrozenTablePane(JTable table, int colsToFreeze){
    super(table);
    TableModel model = table.getModel();
    //create a frozen model
    TableModel frozenModel = new DefaultTableModel(
    model.getRowCount(),
    colsToFreeze);
    //populate the frozen model
    for (int i = 0; i < model.getRowCount(); i++) {
    for (int j = 0; j < colsToFreeze; j++) {
    String value = (String) model.getValueAt(i, j);
    frozenModel.setValueAt(value, i, j);
    //create frozen table
    JTable frozenTable = new JTable(frozenModel);
    //remove the frozen columns from the original table
    for (int j = 0; j < colsToFreeze; j++) {
    table.removeColumn(table.getColumnModel().getColumn(0));
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    //format the frozen table
    JTableHeader header = table.getTableHeader();
    frozenTable.setBackground(header.getBackground());
    frozenTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    frozenTable.setEnabled(false);
    //set frozen table as row header view
    JViewport viewport = new JViewport();
    viewport.setView(frozenTable);
    viewport.setPreferredSize(frozenTable.getPreferredSize());
    setRowHeaderView(viewport);
    setCorner(JScrollPane.UPPER_LEFT_CORNER, frozenTable.getTableHeader());
    }

  • BW BPS Web Page(BSP App): how to Freeze columns in a ALV Layout?

    Hi Gurus,
    I'm trying to freeze the first columns of my layout when scrolling to the right.
    I got the scrollbar including html(javascript) text element in my web page, but i for the moment I'm stuck with the freezing column.
    I'd appreciate some help.
    Thanks in advance.
    IP

    Hi, the problem is in the Web page, not in the layout definition.
    The first thing i did was to freeze columns in the layout definition, but when you build your web page(bps_wb) those settings aren´t applying.
    I guess i need javascript to do it. Any suggestion?
    Thanks

  • Hiding a column in jtable made from DefaultTableModel.

    I have made my jtable from DefaultTableModel.
    I want to keep one column in the jtable as hidden storing some data containing neccessary information like the "path of the file"
    which need not be shown to the user.
    Please tell me how I can hide one column in the Jtable.
    please provide siome link or code for the same.
    Tia,
    Sarwa

    dayanandabv wrote:
    [http://search.sun.com/search/onesearch/index.jsp?qt=hide+column%2B+JTable&rfsubcat=&col=developer-forums]
    My thought exactly.
    db

  • Need suggestion in getting data using JDBC

    Hi all need suggestion,
         i had a VO corresponding to database table.
         when i am try to get the records from that table,
         how can i initialize the particular column value to the
         corresponding VO setter method.
         please do the needful.

    Hello inform2csr,
    Your question is not so clear.
    Can you be more precise?
    What is VO?

  • Need suggestion for designing a BEx report

    Hi,
    I need suggestions for designing a BEx report.
    Iu2019ve a DSO with below structure:
    1. Functional Location u2013 Key
    2. Maintenance Plan u2013 Key
    3. Maintenance Item u2013 Key
    4. Call # - Key
    5. Cycle u2013 Data Field
    6. Planned Date u2013 Data Field
    7. Completion Date u2013 Data Field
    This DSO contains data like:
    Functional -
    Plan --- Item -
    Call# --- Cycle -
    Planned Dt -
    Completion Dt
    Location
    11177 -
         134 -
         20 -
         1 -
    T1 -
         02-Jan-2011 -
         10-Jan-2011
    11177 -
         134 -
         20 -
         2 -
    T2 -
         15-Feb-2011 -
    11177 -
         134 -
         20 -
         3 -
    T1 -
         15-Mar-2011 -
    11177 -
         134 -
         20 -
         4 -
    M1 -
         30-Mar-2011 -
    25000 -
         170 -
         145 -
         1 -
    T1 -
         19-Jan-2011 -
         19-Jan-2011
    25000 -
         134 -
         145 -
         2 -
    T2 -
         20-Feb-2011 -
         25-Feb-2011
    25000 -
         134 -
         145 -
         3 -
    T1 -
         14-Mar-2011 -
    Now Iu2019ve to create a report which will be executed at the end of every month and should display the list of Functional Locations whose Cycles were planned in that particular month, along with the last completed Cycle/Date.
    Thus based upon above data, if I execute report at the end of (say) March then report must display:
    Functional ---     Curr. Cycle --- Planned Date --- Prev. completed Cycle --- Prev Completed Date
    Location
    11177 -
         T1 -
         15-Mar-2011 -
    ---     T1 -
    --     10-Jan-2011
    11177 -
         M1 -
         30-Mar-2011 -
    ---     T1 -
    --     10-Jan-2011
    25000 -
         T1 -
         14-Mar-2011 -
    ---     T2 -
    --     25-Feb-2011
    Any idea how can I display Previous Completed Cycle and Completion Date (i.e. the last two columns)?
    Regards,
    Vikrant.

    hi vikrant,
    You can a Cube at the reporting layer  which gets data from DSO and which has these 2 extra characteristics completion date and previous cycle along with other chars and keyfigures from DSO.
    You can populate these  based on your logic in the field routine.
    Hope it helps.
    Regards
    Dev

  • How to set different renderers to different cells in same column of JTable?

    Hello Friends,
    I need your help again...
    Does any body knows, how to set different renderer's for different cells of same column in JTable..??
    For ex.
    Col1 Col2 Col3 Col4
    A       A       A      A
    A       A       A      B
    A       A       A      C
    A       A      A       D
    Where A B C D would be different Renderers.  I want set exactly same ,,, ie. one column with different renderer at different cell positions..
    Right now i m setting renderer using statement bellow :
    table.getColumnModel().getColumn(int).setCellRenderer(rederer_Instance);But with this, effect in the last renderer is applicable whole column....
    Can any body help me out ?????????
    please refer this thread for similar kind of discussion...
    http://forums.sun.com/thread.jspa?forumID=57&threadID=571445Thanks
    Suyog

    Please refer to the first reply of [this thread|http://forums.sun.com/thread.jspa?forumID=57&threadID=571445] for the answer. If you have a specific problem implementing it, post you code with a specific question.

  • Keyboard Access For a Column in JTable with default editor as JComboBox

    I want to get Key board access for a column in JTable.
    The user should be able to select from a drop down list for the column with default
    editor set as JComboBox.
    Presently,it works fine with mouse,also I am able to focus it with Keyboard using
    ALT+Up keys,but how to make drop down list appear.
    Plz help,it's urgent.
    Thanks in Advance

    Hi,
    In addition to setting DO_SUM = 'X' you need to specify function in H_FTYPE field. It should be set to 'AVG' in your case.
    ls_fielcat-do_sum = 'X'.
    ls_fieldcat-h_ftype = 'AVG.

  • Soap to Soap scenario(need suggestions)

    Hi All,
    I have a scenario to be developed. Its a soap to soap scenario. We need to send  a request with target site name and list name in the URL.
    As there are 4 different sites each has different list with different columns. We need to retrieve these data in a single structure and send it back to the source system( as response). Now I am stuck in the response structure creation. Anybody has any idea? Please suggest.

    Hello,
    I would suggest you to check below blog and using this create ur target URL (or action) dynamically to retrieve data from  different sites.
    Dynamically providing URL and action values  to receiver SOAP communication channel
    Now for the response, i would suggest you to use JM. So, in java code parse (whatever) response which is coming from WS, send the same to ur sender system - By this way u don't have to worry abt creating response structures in PI for each site.
    Hope i understood ur question correctly and if not then do correct me.
    Thanks
    Amit Srivastava

  • How to reorder columns in JTable between sessions without serialization?

    I have a situation where the column widths and names of a JTable are saved to DB(there is no serialization). Upon starting a new session, the JTable needs to be displayed with reordered column.
    For example, let us say the default JTable has columns as A, B, C, D ...
    The user rearranges the columns to B, A, D, C....
    How do I tell JTable model to not use the default but the new values? Is serialization the only way?
    Here is some sample code I use to set the widths. But what I really want to do is reorder columns by reading their names.
    Thanks for your help
    for(int i=0;i<count;i++) {
                        int width=(int)(ttsDefaults.getColumnWidth(i)*
                             DesktopEnvironment.getInstance().getDesktopRootFrame().getWidth());
                        sumWidth+=width;
                        treeTable.getColumnModel().getColumn(i).setPreferredWidth(width);
                        //treeTable.getColumnModel().getColumn(i).setWidth(width);
                   }

    Hi Jules,
    You need a user with XDBADMIN rights to access the WebDav. Once you have access, you can open the URL as webfolder (in IE).
    Regards,
    Christian

  • Hide a column in JTable

    Dear all,
    I want to hide a column in JTable object, I already tried resize it to 0 but the effect is not good, I also cannot remove the column, since I need this column for other process.
    So, any other good idea besides resizes and remove?
    Thank you very much!

    I have tried that too, but the column isn't hide, the size is not actually come to 0,...That's because JTable has a default minimum width of 15.... if you want to hide the column, you must set the minwidth as well. For example:
    myTable.getColumnModel().getColumn(column_to_hide).setMinWidth(0);
    myTable.getColumnModel().getColumn(column_to_hide).setPreferredWidth(0);;o)
    V.V.

  • To setup scrollbars for individual columns in JTable

    Hi,
    I need to setup individual scrollbars for the
    columns in JTable.
    Can anybody help?
    Thanks in advance.
    Rgds,
    sita

    Hi,
    I need to setup individual scrollbars for the
    columns in JTable.If i understand you correctly, you want to have a scrollbar for every column. If so, you will need a new instance of JTable and JScrollPane for every column, but that's a lot of work if you want to do it fancy.
    The good news, is you can reuse the table model.
    You could do something like that.
    for (int i= 0; i < model.getColumnCount(); i++) {
        JTable table = new JTable();
        table.setAutoCreateColumnsFromModel(false);
       //container
        someContainer.add(new ScrollPane(table), null/* or some layout constrains*/);
        TableColumn tc = new TableColumn(i, 120);
        tc.setHeaderValue(model.getColumnName(i));
        table.addColumn(tc);
    Can anybody help?
    Thanks in advance.
    Rgds,
    sita

  • Freeze columns and rows easily

    I am new to numbers and although I had some difficulties, I have yet to freeze columns and rows in a simple way as in excel. I need to find a tool to focus titles without merging cells, this is something like "Center Across Selection". There is this tool? How I can actually freeze columns and rows easily?

    Numbers automatically repeats the column headers when you are in "Page View".  To enable page view select the menu item "View > Show Print View".
    There is no center across selection.  You can add a text box which you place in front of your table that is as wide as the group of cells you wish to centered on, with the text formatted so it is centered.
    I left the text box above the table, but you should move on top of like:

  • Insert new boolean type column in jtable

    how can i insert new boolean type column or columns in jtable while my program is runing?
    thanks for your answers...

    Save your dukes and see the code I posted at http://forum.java.sun.com/thread.jsp?forum=17&thread=548443&tstart=0&trange=15
    You need the underlying 2d data array be dynamic. I chose Vectors.

Maybe you are looking for