How can I get rid of the gray area that is under/to the right of JTable cells when there are only a few cells?

Sandip Chitale

The 'gray area to the right' happens when the column resize policy is AUTO_RESIZE_OFF. It is controlled using the following JTable API.

public void sizeColumnsToFit(int policy)

If you set any other policy as per JavaDoc API that problem should go away.

For the 'gray area under' you need to do -
JPanel p = new JPanel(new BorderLayout());
p.setOpaque(true);
p.setBackground(SystemColor.window);
JTable table = new JTable(/*your table model etc*/);
JScrollPane sp = new JScrollPane(table);
p.add(sp, BorderLayout.CENTER);
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact