SimpleTable(LAB 3)
import java.awt.*;
import javax.swing.*;
class SimpleTable extends JFrame{
private static final int DEFAULT_WIDTH=400;
private static final int DEFAULT_HEIGHT=180;
private Object[][]cells={
{"อาทิตย์","สีแดง","Sunday","Red"},
{"จันทร์","สีเหลือง","Monday","yellow"},
{"อังคาร","สีเขียว","Tuesday","Green"},
{"พุธ","สีชมพู","Wednesday","Pink"},
{"พฤหัสบดี","สีฟ้า","Thursday","Blue"},
{"ศุกร์","สีขาว","Friday","White"},
{"เสาร์","สีส้ม","Saturday","Orange"},
};
private String[]columnNames = {"วัน","สี","Day","Color"};
public SimpleTable(){
setTitle ("Simple Table");
setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);
JTable table=new JTable (cells,columnNames);
add (new JScrollPane(table),BorderLayout.CENTER);
}
public static void main(String[] args){
JFrame frame=new SimpleTable();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น