1

I have a table each cell contains a image. if the image size is more than row height, I have added JScrollPane. Now when I run the application, scroll is visible in each cell but I'm not able to scroll it.

How can I do it?

Below is the code I'm using to add scroll pane.

Any sample code will be appreciated.

     private final JTable table = new JTable(model)

    {

    @Override public Component prepareRenderer(TableCellRenderer tcr, int      row, int column) 

    {
         Component c = super.prepareRenderer(tcr, row, column);
         if(isRowSelected(row))              
         {
             c.setForeground(getSelectionForeground());
             c.setBackground(getSelectionBackground());             
         }             
       else{
             c.setForeground(getForeground());
             c.setBackground((row%2==0)?evenColor:getBackground());
         }
         JScrollPane _pane=new JScrollPane(c);
         table.setRowHeight(100);
         return _pane;
     }
};
Andrew Thompson
  • 166,747
  • 40
  • 210
  • 420
Rama Krishna
  • 120
  • 8
  • 1
    Seems like the making of an unusable GUI, when you expect the user to scroll in order to see the content of table cells. – Andrew Thompson Apr 01 '15 at 06:03
  • may be following links will helpful to you. http://stackoverflow.com/questions/6388453/adding-a-jscrollpane-component-to-a-jtable-column http://stackoverflow.com/questions/9395554/scrollable-cells-in-jtable – anand kulkarni Apr 01 '15 at 06:04

1 Answers1

0
  1. Right click on your jscrollpane
  2. Properties
  3. HOrizontal scrollbarpolicy = always
  4. Vertical scrollbarpolicy = always

To be able to scroll Right Click on Jtable Autocreatecolumnfrommodel =false(deactivaded)

Isbelmont
  • 21
  • 1
  • 7