
I am doing one project on java Swings,
in this i have created one jframe where i defined some JButtons and Jcombobox's,
here i need to insert one JTable with headers(IN CURRENT JFrame only).pls help me urgently.
Thanks in Advance.

Here is a code that displays button, table and jcombobox.
import javax.swing.*;
import java.awt.*;
public class SimpleJTableExample{
public static void main(String[] args){
new SimpleJTableExample();
}
public SimpleJTableExample(){
JFrame frame = new JFrame("Creating JTable Component Example!");
JPanel panel = new JPanel();
String data[][] = {{"A","Delhi","1111"},{"B","Mumbai","2222"},
{"C","Kolkata","3333"},{"D","Chennai","4444"}};
String col[] = {"Name","Address","Contact No"};
JTable table = new JTable(data,col);
table.getTableHeader().setReorderingAllowed(false) ;
table.getTableHeader().setResizingAllowed(false);
panel.add(table.getTableHeader() , BorderLayout.NORTH);
panel.add(table, BorderLayout.CENTER);
JPanel pan = new JPanel(new GridLayout(2,2));
JLabel l=new JLabel("Select");
JComboBox combo=new JComboBox();
combo.addItem("A");
combo.addItem("B");
combo.addItem("C");
combo.addItem("D");
JButton b=new JButton("Submit");
pan.add(l);
pan.add(combo);
pan.add(b);
frame.add(pan,BorderLayout.NORTH);
frame.add(panel,BorderLayout.SOUTH);
frame.setSize(300,200);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.