import java.awt.*;
@SuppressWarnings("serial")
public class JTableExample extends JPanel
{
public JTableExample()
{
super(new GridLayout(1, 0));
JTable table = new JTable(5, 4);
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
JScrollPane scrollPane = new JScrollPane(table);
add(scrollPane);
Color light_blue = new Color(205, 235, 255);
scrollPane.setBackground(light_blue);
scrollPane.getViewport().setBackground(light_blue);
table.getTableHeader().setBackground(light_blue);
}
public static void createAndShowGUI()
{
JFrame frame = new JFrame("JTableExample");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTableExample newContentPane = new JTableExample();
frame.setContentPane(newContentPane);
frame.pack();
frame.setVisible(true);
}
}
public class Driver
{
public static void main(String[] args)
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
JTableExample.createAndShowGUI();
}
});
}
}
No comments:
Post a Comment