Latest Java Program For Table Creation 2011

Latest Java Program For Table Creation 2011

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class TableView extends JFrame implements ActionListener {
Object [][] data = {
{"bit","binary","byte"},
{"computer","CISCO","control"},
{"data","debug","dictionary"},
{"data","debug","dictionary"},
{"data","debug","dictionary"},
{"data","debug","dictionary"},
};

Object [] heading = {"B","C","D"};

public TableView(){
setLayout(new GridBagLayout());

GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 0.5;

c.gridx = 0;
c.gridy = 0;
c.ipady = 50;
c.gridwidth = 3;
JTable table = new JTable(data, heading);
JScrollPane pane = new JScrollPane(table);
add(pane, c);

c.gridwidth = 0;
c.ipady = 0;

c.gridx = 0;
c.gridy = 1;
JPanel p1 = new JPanel(new FlowLayout());
JButton add = new JButton("Add");
JTextField tf = new JTextField(10);
p1.add(add);
p1.add(tf);

add(p1, c);

setVisible(true);
setSize(400, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

public static void main(String [] args){
TableView tv = new TableView();
}

public void actionPerformed(ActionEvent e){

}
}

Recommended Posts



Privacy Policy

All the Colleges, Schools, Universities, Top lists, Interview question paper, Programming, Tips, Tutorials and all other's just information purpose only. We are not responsible for any damages caused to you.