Tables in more attractive way
Hi guys
I have the following program please can you help me in :-
1\ colouring columns names of tables and ability of settinglines thickness that I want
of my table
2\ where the column names of the table named wabil in my application
import java.awt.Color.*;
import java.awt .*;
import javax.swing.*;
import java.util.*;
import javax.swing.JTable.*;
public class sannaa extends JFrame{
JFrame frame=new JFrame();
public sannaa() {
Container contentPane= getContentPane();
Container content = getContentPane();
String[] columnNames = {"First Name",
"Last Name",
"Sport",
"# of Years",
"Vegetarian"};
Object[][] data = {
{"Mary", "Campione",
"Snowboarding", new Integer(5), new Boolean(false)},
{"Alison", "Huml",
"Rowing", new Integer(3), new Boolean(true)},
{"Kathy", "Walrath",
"Knitting", new Integer(2), new Boolean(false)},
{"Sharon", "Zakhour",
"Speed reading", new Integer(20), new Boolean(true)},
{"Philip", "Milne",
"Pool", new Integer(10), new Boolean(false)}
};
JTable table = new JTable(data, columnNames);
setTitle("rot");
JScrollPane scrollPane = new JScrollPane(table);
getContentPane().add( scrollPane );
table.setPreferredScrollableViewportSize(new Dimension(700, 70));
String[] colum = {"First Name",
"Last Name",
"Sport",
"# of Years",
"Vegetarian"};
Object[][] rami = {
{"Mary", "Campione",
"Snowboarding", new Integer(5), new Boolean(false)},
{"Alison", "Huml",
"Rowing", new Integer(3), new Boolean(true)},
{"Kathy", "Walrath",
"Knitting", new Integer(2), new Boolean(false)},
{"Sharon", "Zakhour",
"Speed reading", new Integer(20), new Boolean(true)},
{"Philip", "Milne",
"Pool", new Integer(10), new Boolean(false)}
};
JTable wabil =new JTable(rami, colum );
JScrollPane scrolPane = new JScrollPane(wabil);
wabil.setPreferredScrollableViewportSize(new Dimension(700, 70));
getContentPane().add( scrolPane );
contentPane.setBackground( Color.white);
content.setBackground(Color.yellow);
JPanel panel=new JPanel(new BorderLayout(500,500) );
JPanel pane=new JPanel(new BorderLayout( ) );
contentPane.setLayout(new FlowLayout( ));
content.setLayout(new FlowLayout( ));
contentPane.add(panel);
content.add(pane);
JLabel hellolabel=new JLabel("Transaction");
hellolabel.setForeground(Color.black);
pane.add(hellolabel , BorderLayout.PAGE_START);
pane.setBackground(Color.blue);
panel.setBackground( Color.white );
panel.setLayout(new BorderLayout());
panel.add(table.getTableHeader( ), BorderLayout.PAGE_START);
pane.add(wabil.getTableHeader(),BorderLayout.CENTER);
setVisible(true);}
public static void main (String [] args){
sannaa van=new sannaa( );
}}
Thanks

