Fixed Column and Scrollable JTable problems

I've implemented a table that has the first column fixed, while 2nd to end are scrollable.
following the fixedModel examples, i am able to get this working..but im not able to update it. the exmples tho, subclass AbstractTableModel and use anonymous classes to define it...mine uses a class that subclasses DefaultTableModel..but DefaultTableModel subclasses AbstractTableModel...so i think it should be ok.
i have 2 table models, one for the fixed, and one for the scrollable..they use the same data/column arrays...then i create 2 tables that with these models...
initially i have no data Object[][] data = new Object[0][0]) and a bunch of column names
it works fine..but i have trouble updating it with real data
i use fixedModel.setDataVector(...) and scrollModel.setDataVector(...) to update...but it doesnt work..i dont get any exceptions or anything..just nothing comes up...revalidating the tables doesnt work
if i choose not to use the fixed/scrollable tables..and just use one normal table with setDataVector..it works fine
any ideas?
heres the code:
fixedModel = new SortableTableModel() {
    /*  for sorting to work correctly  */
    public Class getColumnClass(int col) {
       return getValueAt(0, col).getClass();
    public boolean isCellEditable(int row, int col) {
        return false;
    //new methods
    public int getColumnCount() {
        return 1;
    public int getRowCount() {
        return data.length;
    public String getColumnName(int col) {
        return (String)columnNames[col];
    public Object getValueAt(int row, int col) {
        return data[row][0];
fixedModel.setDataVector(data,columnNames);
scrollModel = new SortableTableModel() {
    public Class getColumnClass(int col) {
        return getValueAt(0, col).getClass();
    public boolean CellEditable(int row, int col) {
        return false;
    //new methods
    public int getColumnCount() {
        return columnNames.length -1;
    public int getRowCount() {
        return data.length;
    public String getColumnName(int col) {
        return (String)columnNames[col+1];
    public Object getValueAt(int row, int col) {
        return data[row][col+1];
    public void setValueAt(Object obj, int row, int col) {
        data[row][col +1] = obj;
scrollModel.setDataVector(data, columnNames);
ListSelectionModel lsm = fixedTable.getSelectionModel();
lsm.addListSelectionListener(new SelectionListener(true));
lsm = scrollTable.getSelectionModel();
lsm.addListSelectionListener(new SelectionListener(false));
fixedTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
scrollTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JViewport viewport = new JViewport();
viewport.setView(fixedTable);
viewport.setPreferredSize(fixedTable.getPreferredSize());i really need to get this fixed..thanks for the help!

i fixed the problem a couple days ago
my anonymous class for the fixed and scrollable table models defines the data given from a 2D Object array..and not a vector of vectors, which i was using when setting the data :P
oops...
thanks for the help tho.

Similar Messages

  • Export file - fixed columns and remove dimensions

    Hello Experts
    I wan't to use the standard export package ang get dimensions fixed in specific columns and also remove some dimensions.
    The problem is that i always get the dimensions randomly in columns and when i am able to remove dimensions, the dimensions are removed randomly, please see *MAPPING and result below, does anyone know how to do this? Or have an example? I have used the standard example files but they have not helped....
    *OPTIONS
    FORMAT = DELIMITED
    HEADER = YES
    DELIMITER=
    VALIDATERECORDS=NO
    ROUNDAMOUNT = 7
    OUTPUTHEADER=
    OUTPUTDELIMITER=
    SPECIFICMAPPING=YES
    *MAPPING
    ENTITY=*COL(1)
    TIME=*COL(2)
    ACCOUNT=*COL(3)
    RPTCURRENCY=*COL(4)
    AMOUNT=*COL(5)
    ACCOUNT,ENTITY,RPTCURRENCY,TIME,AMOUNT
    NON_FLOW,ADT5_E,ACTUAL,ANA_TONS,TOTALADJ
    NON_FLOW,568U_E,ACTUAL,ANA_TONS,TOTALADJ
    Best regards
    Jonas

    Given the nature of OLAP and FACT tables, I do not beleive that you are able to disassociate a dimension from the export process.  So, I don't think that you may choose the dimensions to export, plus there method of being written to a file may just be alphabetical. I would export the complete details and then manipulate the details during an import process. The only other alternative that I can think of is to write a custom SSIS SQL script, to allow for FACT member aggregation if you choose to remove a dimension.
    But I would need to test further. Hope this helps.

  • Preview and scrollable text problems

    Is anyone else having problems getting the scrollable text function to work in an overlay to a fixed layout ePub? I have the latest version of InDesign CC, purchased last week.
    Here is a picture of my file. As you can see, it's pretty darn simple. Content box is on the right. You can't see the entire box but It is long enough to fit all of my text. On the left, I created a container box, wider but shorter than the content box. I then selected the content and used Paste Into to put the content into the container. Next, I selected the container, went to Folio Overlays, and I designated the content box as vertical scrolling, start at upper left, and Vector format. But when when I tried to preview it (more on preview problems in a minute), the container appears as a simple text box with no scrolling capability. I've asked the Adobe help people and they don't seem to have any ideas yet.
    As far as preview goes, well, I can export to Adobe Digital Editions or I can look at the page in Window/Interactive/EPUB Interactivity Preview. But File/Folio Preview just processes the page and then returns nothing. And the same thing happens when I hit Preview in the Folio Overlays panel.
    I'd love to know if this is unique to my system or a common problem. Since I only purchased CC to produce annotated books, there is not much I can do without it. And if CC doesn't do it, does anyone have a suggestion for something a non-programmer could use to get the same result?
    Thanks for any help.

    Scrollable frames are a DPS -- Digital Publishing Suite-- function (as are all other effects from the Folio Overlay panel). Those are a different beast than Fixed-Layout EPUBs.
    For fixed-layout, all interactivity is supported (any panel in the Windows > Interactive flyout) except for Forms, Page Transitions, and the two Animation presets Smoke and Blur. Note that the panels Folio Builder and Folio Overlays are not part of the Interactive group of panels.
    I know it's very confusing!
    If you're trying to create an *app* then you use DPS, and you should be asking this question in the DPS forum.
    Digital Publishing Suite
    If you're trying to create an *ebook* then this is the forum to post in. 
    You might find my new lynda.com video tutorial course, Creating Fixed Layout EPUBs from InDesign CC, to be helpful. A bunch of the videos are free and may be all you need. To watch the others, though, you'll need a subscription. You can use my Free Pass URL to get a free week of open access to all the lynda.com videos.
    Watch the Online Video Course Creating Fixed-Layout EPUBs with InDesign CC
    Free pass: http://lynda.com/freepass/amconcepcion
    AM

  • External table, fixed columns and variable record length..

    Hi all,
    I'm trying to create an exernal table of a txt-file. Te records are delimited by newlines and the field lengths are fixed. But...
    When one or more of the last columns are missing the record is truncated.
    Here's the problem: the access parameter "missing field values are null" doesn't seem to work here.. And all incomplete lines are rejected!
    Any ideas??

    Well, seems like I was on a wild goose chase here.
    The original version of the file was not in UTF8 but in ANSI. But for some reason somebody thought it was necessary to convert the file to UTF8.
    So, although my question isn't answered yet, my problem has been solved.

  • [dataTable] fixed header and scrollable content all-in-one

    Hi folks,
    In your opinion, how can I use CSS like here (see [http://www.imaputz.com/cssStuff/bigFourVersion.html] or [http://web.tampabay.rr.com/bmerkey/examples/nonscroll-table-header.html]) in a "h:dataTable", to have a fixed header? Have you a quick example?
    Thank you very much for your support.
    G.

    The h:dataTable just renders a HTML table. Apply the same using the standard attributes and standard way of writing CSS.

  • Scroll Fix Column in JTable

    I have see a lots of examples of whow to create fix column into JTable.
    But all the examples have the same problems.
    When I wont to scroll over the fix column the vertical scroll bar of the no fix column dont move, so the no fix column dose not move and the fix columns and no fix columns aren?t alined.
    If sameone have same example, send it please !!!!
    Thanks !!!
    Pablo

    In a recent project I've had the same problem.
    After a long research at the Swing forum at java.sun.org and google I found out that
    1. Currently there is no proper Open Source solution
    2. All the postings at sun are good concepts, but far away from solutions
    3. The only (for me )acceptable commercial solution is the JCTable from Quest (formerly KGroup)
    Since I want to have full control over the source code of the table, I decided to collect all the tips from this forums and write my own table.
    Here is a first try:
    http://jroller.com/resources/kriede/CoolTable.java
    The main idea is to have two tables, one for the locked columns (= fixed columns = frozen columns) and one for the scrollable columns. With all the tips from this forum it was more or less a puzzle to make it work pretty.

  • JTable (View column Title & Scrollable) Problem ... Help

    Hi,
    I have created a JTable on a JPanel, which is positioned on a main frame in CardLayout. The problem I have is that I can't view the title for each column and it won't be scrollable...
    here is short forma of what I did
    setSize(750, 850); (main frame size)
    m_data = new AppLetterTableData(); (contains the table data)
    jTable1 = new JTable();
    jTable1.setAutoCreateColumnsFromModel(false);
    jTable1.setModel(m_data);
    for (int k = 0; k <AppLetterTableData.m_columns.length; k++) {
    DefaultTableCellRenderer renderer = new
    DefaultTableCellRenderer();
    renderer.setHorizontalAlignment(
    AppLetterTableData.m_columns[k].m_alignment);
    TableColumn column = new TableColumn(k,
    AppLetterTableData.m_columns[k].m_width, renderer, null);
    jTable1.addColumn(column);
    } (when I debug this line of code I see the columns contain title)
    JTableHeader header = jTable1.getTableHeader();
    header.setUpdateTableInRealTime(false);
    JScrollPane ps = new JScrollPane();
    ps.getViewport().add(jTable1);
    getContentPane().add(ps, BorderLayout.CENTER);
    *** I can view the data but not the header... and no matter how much data I have it still won't be scrollable..
    I very much appreciate your feedbacks

    Thanx to both of you.... My problem was that I was adding JTable1 to the JPanel not the scrollPane...
    so I had
    JScrollPane scrollPane = new JScrollPane(table);
    panel1.add(table, BorderLayout.CENTER);
    instead of
    JScrollPane scrollPane = new JScrollPane(table);
    panel1.add(scrollPane, BorderLayout.CENTER);
    well my problem solved and I'm happy now... Once again thanx for your responds.

  • JTable fixed Row and Column in the same window

    Hi
    Could anyone tip me how to make fixed row and column in the same table(s).
    I know how to make column fixed and row, tried to combine them but it didnt look pretty.
    Can anyone give me a tip?
    Thanks! :)

    Got it to work!
    heres the kod.. nothing beautiful, didnt clean it up.
    * NewClass.java
    * Created on den 29 november 2007, 12:51
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package tablevectortest;
    * @author Sockan
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    public class FixedRowCol extends JFrame {
      Object[][] data;
      Object[] column;
      JTable fixedTable,table,fixedColTable,fixedTopmodelTable;
      private int FIXED_NUM = 16;
      public FixedRowCol() {
        super( "Fixed Row Example" );
        data =  new Object[][]{
            {      "","A","A","A","",""},
            {      "a","b","","","",""},
            {      "a","","c","","",""},
            {      "","","","d","",""},
            {      "","","","","e",""},
            {      "","","","","","f"},
            {      "","b","","","",""},
            {      "","","c","","",""},
            {      "","","","d","",""},
            {      "","","","","e",""},
            {      "","b","","","",""},
            {      "","","c","","",""},
            {      "","","","d","",""},
            {      "","","","","e",""},
            {      "","","","","","f"},
            {      "I","","W","G","A",""}};
        column = new Object[]{"A","B","C","D","E","F"};
        AbstractTableModel fixedColModel = new AbstractTableModel() {
          public int getColumnCount() {
            return 1;
          public int getRowCount() {
            return data.length;
          public String getColumnName(int col) {
            return (String) column[col];
          public Object getValueAt(int row, int col) {
            return data[row][col];
          public boolean CellEditable(int row, int col) {
            return true;
        AbstractTableModel    model = new AbstractTableModel() {
          public int getColumnCount() { return column.length-2; }
          public int getRowCount() { return data.length - FIXED_NUM; }
          public String getColumnName(int col) {
           return (String)column[col+1];
          public Object getValueAt(int row, int col) {
            return data[row][col+1];
          public void setValueAt(Object obj, int row, int col) {
            data[row][col+1] = obj;
          public boolean CellEditable(int row, int col) {
            return true;
        AbstractTableModel fixedTopModel = new AbstractTableModel() {
          public int getColumnCount() { return 1; }
          public int getRowCount() { return data.length - FIXED_NUM; }
          public String getColumnName(int col) {
           return (String)column[col];
          public Object getValueAt(int row, int col) {
            return data[row][col];
          public void setValueAt(Object obj, int row, int col) {
            data[row][col] = obj;
          public boolean CellEditable(int row, int col) {
            return true;
        AbstractTableModel fixedModel = new AbstractTableModel() {     
          public int getColumnCount() { return column.length-2; }
          public int getRowCount() { return FIXED_NUM; }
          public Object getValueAt(int row, int col) {
            return data[row + (data.length - FIXED_NUM)][col+1];
        table = new JTable( model );
        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        fixedTable = new JTable( fixedModel );
        fixedTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        fixedTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        fixedColTable= new JTable(fixedColModel);
        fixedColTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        fixedColTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        fixedTopmodelTable = new JTable(fixedTopModel);
        fixedTopmodelTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        fixedTopmodelTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);   
        JScrollPane scroll      = new JScrollPane( table );
         scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
         scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        JScrollPane fixedScroll = new JScrollPane( fixedTable ) {
          public void setColumnHeaderView(Component view) {}
        fixedScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        fixedScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        JScrollBar bar = scroll.getVerticalScrollBar();
        JScrollBar dummyBar = new JScrollBar() {
          public void paint(Graphics g) {}
        dummyBar.setPreferredSize(bar.getPreferredSize());
        scroll.setVerticalScrollBar(dummyBar);
        final JScrollBar bar1 = scroll.getHorizontalScrollBar();
        JScrollBar bar2 = fixedScroll.getHorizontalScrollBar();
        bar2.addAdjustmentListener(new AdjustmentListener() {
          public void adjustmentValueChanged(AdjustmentEvent e) {
            bar1.setValue(e.getValue());
        JViewport viewport = new JViewport();
        viewport.setView(fixedColTable);
        viewport.setPreferredSize(fixedColTable.getPreferredSize());
        fixedScroll.setRowHeaderView(viewport);
        fixedScroll.setCorner(JScrollPane.UPPER_LEFT_CORNER, fixedColTable
            .getTableHeader());   
        JViewport viewport2 = new JViewport();
        viewport2.setView(fixedTopmodelTable);
        viewport2.setPreferredSize(fixedTopmodelTable.getPreferredSize());
        scroll.setRowHeaderView(viewport2);
        scroll.setCorner(JScrollPane.UPPER_LEFT_CORNER, fixedTopmodelTable
            .getTableHeader()); 
        scroll.setPreferredSize(new Dimension(600, 19));
        fixedScroll.setPreferredSize(new Dimension(600, 100)); 
        getContentPane().add(     scroll, BorderLayout.NORTH);
        getContentPane().add(fixedScroll, BorderLayout.CENTER);   
      public static void main(String[] args) {
        FixedRowCol frame = new FixedRowCol();
        frame.addWindowListener( new WindowAdapter() {
          public void windowClosing( WindowEvent e ) {
            System.exit(0);
        frame.pack();
        frame.setVisible(true);
    }

  • Problem adding columns and rows in JTable

    hi, hope somebody can help me
    i have some problems when i add columns and later i try to set number of rows in JTable, ocurr some exceptions
    my code is something like thisJTable tabla = new JTable();
    TableColumn tc = new TableColumn();
    tc.setHeaderValue("col1");
    tc.setPreferredWidth(20);
    tabla.getColumnModel().addColumn(tc);up to here everything goes well, my table shows the column, but when i add this line((DefaultTableModel)tabla.getModel()).setNumRows(1);ocurrs the next exception
    Exception occurred during event dispatching:
    java.lang.ArrayIndexOutOfBoundsException: 0 >= 0....
    any ideas????

    oks, that would work when the JTable is created, but now we say that I require a method which adds a new row to the JTable a some moment of execution
    Look some of my code
    i have this in a JFrame...
    JTable tabla = new JTable();
    DefaultTableModel tm = new DefaultTableModel();
    tabla.setModel(tm);
    agrCol("Col1", 80);
    agrCol("Col2", 160);
    agrFil();
    agrFil();
    agrCol(String col, int lon) {
      tm.addColumn(col);
      tabla.getColumn(col).setPreferedWith(lon);
    agrFil() {
      tm.setRowCount(tabla.getRowCount() + 1);
    the jtable shows the 2 columns and 2 rows, but the setPreferedWith work only in the last col, i'm confused

  • Scrollable table with fixed column headings problem

    Dear list members,
    A while ago I asked on this forum for a way to code a
    scrollable table with fixed headings and I was kindly given the
    HTML and CSS code to do that. Using the method I was given I coded
    the following simple test case. It works under IE but under
    Netscape the column headings scroll up instead of remaining fixed.
    The code works fine in IE. Can anyone tell me what I'm doing wrong
    or if there is a workaround.
    Thanks,
    Harry

    The method you were given will only work in IE because only
    IE understands
    "expression" in CSS rules.
    I'm afraid things are going to be a little more complicated
    for you, but
    it's not impossible.
    Give this method a shot:
    http://www.imaputz.com/cssStuff/bulletVersion.html
    "harryspier" <[email protected]> wrote in
    message
    news:e53s1a$dv9$[email protected]..
    > <style>
    > div .headings {position:relative;
    > top:expression(this.offsetParent.scrollTop);}
    > </style>

  • Making a single column horizontally scrollable for JTable

    Hello Everyone and thank you for reading my post.
    I have been trying for the last 3 days to make a single column horizontally scrollable on my JTable but for some reason I can not get it to work.
    I simplyfied my example to 2 columns and 5 rows where
    the rows in the first column have long text and it will have a horizontal scroll bar to scroll to the end of the text, similiar to split in Excel.
    The second column it doesn't matter
    Thanks again and have a great time,
    Al

    Friend you use table cell renderer for your problem.
    The solution would be like:
    1. Write cell renderer that displays textfield contained in scrollpane.
    2. Apply cell renderer to separate column where you require horizontal scroller.

  • Is it possible to have a fixed column width and a URL link?

    I am trying to achieve having a popup link on a column within a SQL report but also have the report column a certain width. I can have either or however not at the same time.
    What I did was created a SQL report, edited a column and gave it a URL redirect (page in application) as normal.
    For the fixed column width, I used:
    <div style="width:250px; height:54px; overflow:hidden" title="#Comments#">#Comments#</div>On Column Formatting / HTML Expression
    And for the popup URL, I used:
    onclick="window.open(this.href,'_blank','resizable=0,scrollbars=0,width=650,height=300,menubar=0,location=0');return false;" title="Comments"On the Column Link / Link Attributes

    Andy thank you for your reply, however I either am not completly understanding or there is a problem elsewhere.
    I have changed to the code to fit the needs of the application as so:
    !http://i41.tinypic.com/2m6mrh4.jpg!
    App ID: 523
    Page: 23
    Item: P23_STATUS_COMMENT
    Column to select: Comments
    Whenever clicking on the link, the following error is given:
    Expecting p_company or wwv_flow_company cookie to contain security group id of application owner.
         Error      ERR-7620 Could not determine workspace for application ().{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Prob with fixed column widths and word wrapping in viewer

    i have a report where each record has a very long paragraph of text in it.
    In desktop and plus, the text column is at a fixed width and the text just wraps nicely according to the column width.
    But in Viewer, the column widths do not stay fixed, the text does not wrap, and the long text is displayed in a single line that completely stretches the column width off the page and requires a horizontal scroll bar.
    is there anyway to fix the column width in viewer, have the text naturally wrap, and prevent the column stretching. All word wrapping settings are on, but seem to have no effect. I can't seem to find any solution to this.
    Thanks...

    Hi Pritam,
    Per my understanding that you can't see the vertical scrollbar of the ReportViewer controls 2012 to scroll for the grid rows, but can see the vertical scrollbar of the web application, you also can't fix the headers while scrolling, right?
    I have tested on my local environment and can't reproduce your issue, but you have an alternative way to add some css  to the web form's source code to display the vertical scrollbar.
    Details information below for your reference:
    Please check below properties setting of the reportviewer which control the visibility of the scrollbar:
    AsyncRendering="true"
    SizeToReportContent="false"
    Please check if this problem also occur on other version of IE and other type of browser.
    Please check if you have done correct setting of the Fix data to freeze the table header as the step of below:
    http://technet.microsoft.com/en-us/library/bb934257(v=sql.100).aspx
    If step1 doesn't work, please click the source of webform.aspx and add below CSS to add the vertical scrollbar manually:
    #ReportViewer1 {
              overflow-y: scroll;
    Run the application you will see it display as below:
    Similar thread for your reference:
    https://social.msdn.microsoft.com/forums/sqlserver/en-US/f96b3b56-e920-411b-82ea-40467c922e66/reportviewer-control-vertical-scroll-bars
    If you still have any problem, please feel free to ask.
    Regards
    Vicky Liu

  • Fix Columns in JTable ?

    Hi there,
    I want to fix the Columns in my JTable.
    I don�t want to fix the width or high,
    I only want to fix that the user have no rights
    to change the position of a column.
    Whoch atrribute is so set ?
    Thanx
    Stephan

    Just get the TableHeader and follow this
    m_topHeader = m_jobTable.getTableHeader();
    m_topHeader.setReorderingAllowed(false);

  • JTable - make first column not scrollable

    I like to know using one JTable and JScrollPane to make it generically not scroll for the first column.
    Do you set the viewport to start at the second column, if so how?
    Thanks
    Abraham

    Heres a test to run with the renderers and editors for fixed table columns
    See source for FixedColumnScrollPane
    // import libraries required, no space
    public class SimpleTable extends JFrame {
       private static class MyTableCellRenderer extends DefaultTableCellRenderer {
          public MyTableCellRenderer() {
             super();
             setOpaque(true);
             noFocusBorder = new EmptyBorder(1, 2, 1, 2);
             setBorder(noFocusBorder);
          public Component getTableCellRendererComponent(JTable table, Object value,
                                                         boolean isSelected, boolean hasFocus,
                                                         int row, int col) {
             JLabel renderer = (JLabel) super.getTableCellRendererComponent(table, value,
                   isSelected, hasFocus, row, col);
             String cellValue = value.toString();
             renderer.setHorizontalAlignment(SwingConstants.LEFT);
             renderer.setToolTipText(cellValue);
             String headerValue = table.getColumnModel().getColumn(col).getHeaderValue().toString();
             // Use header value for renderers when splitting table columns, dont check by column index
             if (headerValue.length() == 0) {
                renderer.setText("Row " + (row+1));
             if (cellValue.startsWith("a")) {
                renderer.setForeground(Color.blue);
             } else if (cellValue.startsWith("b")) {
                renderer.setForeground(Color.green);
             } else if (cellValue.startsWith("c")) {
                renderer.setForeground(Color.blue);
             } else if (cellValue.startsWith("d")) {
                renderer.setForeground(Color.magenta);
             } else if (cellValue.startsWith("e")) {
                renderer.setForeground(Color.ORANGE);
             return this;
       public class MyTableCellEditor extends AbstractCellEditor implements TableCellEditor {
          private JComponent component = null;
          public Component getTableCellEditorComponent(JTable table, Object value,
                                                       boolean isSelected,
                                                       int row, int col) {
             this.component = new JTextField(value.toString());
             return this.component;
          public Object getCellEditorValue() {
             if (component instanceof JTextComponent) {
                String text = ((JTextComponent) component).getText();
                return text;
             return null;
       public SimpleTable() {
          super("Simple JTable Test");
          setSize(300, 200);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          TableModel mainTableModel = new AbstractTableModel() {
             private static final int ROWS = 1000;
             String colValues[] = {"", "a", "b", "c", "d", "e"};
             String data[][] = new String[ROWS][colValues.length];
             String headers[] = {"", "Column 1", "Column 2", "Column 3", "Column 4", "Column 5"};
             public int getColumnCount() {
                return colValues.length;
             public int getRowCount() {
                return ROWS;
             public String getColumnName(int col) {
                return headers[col];
             // Synthesize some entries using the data values & the row #
             public Object getValueAt(int row, int col) {
                String val = data[row][col];
                if (val == null) {
                   val = colValues[col] + row;
                   data[row][col] = val;
                return val;
             public void setValueAt(Object value, int row, int col) {
                data[row][col] = value.toString();
             public Class getColumnClass(int column) {
                return getValueAt(0, column).getClass();
             public boolean isCellEditable(int row, int col) {
                return (col > 0);
          JTable mainTable = new JTable(mainTableModel);
          TableColumnModel mainColumnModel = mainTable.getColumnModel();
          for (int i = 0; i < mainColumnModel.getColumnCount(); i++) {
             TableColumn tableColumn = mainColumnModel.getColumn(i);
             tableColumn.setCellRenderer(new MyTableCellRenderer());
             tableColumn.setCellEditor(new MyTableCellEditor());
          FixedColumnScrollPane fixedColumnScrollPane
                = new FixedColumnScrollPane(mainTable, 1);
          setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
          JLabel fixedLabel = new JLabel("Fixed Column Table");
          fixedLabel.setFont(new Font("Arial", Font.BOLD | Font.ITALIC, 11));
          getContentPane().add(fixedLabel);
          getContentPane().add(fixedColumnScrollPane);
       public static void main(String args[]) {
          SimpleTable st = new SimpleTable();
          st.setVisible(true);
    }

Maybe you are looking for