在下自己的代码,写成这样后,不知如何着手了,请指点
package menu;
import java.awt.FlowLayout;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionListener;
import java.awt.event.MouseListener;
import javax.swing.table.TableColumn;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;
public class Mjtable extends JFrame {
DefaultTableColumnModel colmodel=new javax.swing.table.DefaultTableColumnModel();
javax.swing.table.DefaultTableModel dtm=null;
TableColumn tmptc=new TableColumn();
TableColumn lasttc=new TableColumn();
JScrollPane js=new JScrollPane();
Object[][] t1val={
{"编号"},{"名称"},{"体型"},{"岁数"},{"身高"}
};
String[] tt={"colname","文本框"};
JTable jt;
JLabel jl=new JLabel();
public Mjtable()
{
add(js);
dtm = new DefaultTableModel(t1val,tt);
colmodel.addColumn(tmptc);
colmodel.addColumn(lasttc);//希望能让这一列变成一个JTextField或是JButton;但现在它是重复显示第一列的内容
jt=new JTable(dtm,colmodel);
js.setViewportView(jt);
}
public static void main(String[] args)
{
Mjtable mj=new Mjtable();
mj.setSize(800,600);
mj.setVisible(true);
}
}
------解决方案--------------------
不会,帮你顶一下
------解决方案--------------------
参考 http://java.sun.com/docs/books/tutorial/uiswing/components/table.html