import java.awt.BorderLayout;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import javax.swing.text.*;
public class cl{
public static void main(String args[]) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton btn = new JButton("btn");
frame.setLayout(null);
btn.setBounds(550,65,100,40);
Object rowData[][] = { { "Row1-Column1", "Row1-Column2", "Row1-Column3" },
{ "Row2-Column1", "Row2-Column2", "Row2-Column3" } };
Object columnNames[] = { "Column One", "Column Two", "Column Three" };
JTable table = new JTable(rowData, columnNames);
JScrollPane scrollPane = new JScrollPane(table);
frame.add(btn);
frame.add(scrollPane);
frame.setSize(900,600);
frame.setVisible(true);
}
}
I am new in java swing ..... I want to add scrollable JTable, would not use any layout that is why use I use setLayout(null). bt i can not see the table on frame how to fix it ??