Name: krT82822 Date: 11/11/98
Previously, the blank space at the bottom of
JScrollPane surrounding a JTable can be set
with:
scrollPane.setBackground(Color.white);
But this no longer works; the white color is
shown around the border of the scroll pane, but
the blank area remains dark gray.
Here's an example:
import com.sun.java.swing.*;
import com.sun.java.swing.event.*;
import com.sun.java.swing.border.*;
import com.sun.java.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class TableTest extends JFrame {
public TableTest() {
super("Menu Test");
setSize(400, 300);
Container contentPane = getContentPane();
String[] columns = {"Column 1", "Column 2"};
String[] row1 = {"1.1", "1.2"};
String[] row2 = {"2.1", "2.2"};
String[] row3 = {"3.1", "3.2"};
String[] row4 = {"4.1", "4.2"};
String[][] data = {row1, row2, row3, row4};
DefaultTableModel model = new DefaultTableModel(data, columns);
JTable table = new JTable(model);
JScrollPane sp = new JScrollPane(table);
// Setting the background no longer works!
sp.setBackground(Color.white);
contentPane.add(sp, "Center");
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel
("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
catch (Exception e) {
System.out.println("Error: exception="+e);
}
TableTest test = new TableTest();
test.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
test.setVisible(true);
}
}
(Review ID: 36844)
======================================================================