JTable
JScrollPane
package jTable;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
public class Main {
JFrame frame ;
Main()
{
frame = new JFrame() ;
String [][] names = {
{"1000","yamen","develeoper"},
{"2000","aymen","data entry"},
{"3000","mohammed","teacher"}
};
String[] header = {"ID","NAME","JOB"};
JTable jtb = new JTable(names,header) ;
JScrollPane s = new JScrollPane(jtb);
jtb.setBounds(40,50,300,400);
frame.add(jtb);
frame.setSize(400, 500);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new Main();
}
}
不会显示列标题。
if($this->request->is('post'))
{
$this->request->data["Leave"]["empid"] = $this->request->data["id"];
$this->Leave->empid = $this->request->data["Leave"]["empid"];
$this->request->data["Leave"]["leave_start"] = $this->request->data["start_date"];
$this->request->data["Leave"]["leave_end"] = $this->request->data["end_date"];
$this->request->data["Leave"]["leave_taken"] = $this->request->data["leave_taken"];
if($this->Leave->save($this->request->data['Leave']))
{
return $this->redirect(array('action' => 'manage_leave'));
}
}
答案 0 :(得分:4)
滚动窗格将显示标题。使用JScrollPane
创建了JTable
,
JTable jtb = new JTable(names, header);
JScrollPane s = new JScrollPane(jtb);
你可能意味着,
frame.add(s);
答案 1 :(得分:0)
尝试使用名称和标题创建TableModel
tableModel = new DefaultTableModel(names, headers);
然后分配JTable
此TableModel
jtb.setModel(tableModel);
然后在框架中添加新的JScrollPane
frame.add(new JScrollPane(jtb));
至少,这就是我在程序中的表现。