关于jTable显示列名的问题

bigman_lfj 2005-06-27 05:13:31
主要代码如下:
public class dlgTest extends JDialog {
JPanel panel1 = new JPanel();
BorderLayout borderLayout1 = new BorderLayout();
String[] strCols = {"ID","Name"};
String[][] strVal = {
{"1","test1"},
{"2","test2"}

};
JTable jTable1 = new JTable(strVal, strCols);

-------------------------------------------
其他地方默认jbuilder设定。

3Q advance............
...全文
380 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Robin_von 2005-07-22
  • 打赏
  • 举报
回复
把JTABLE放到JSCROLLPANE中就可以了!
wmj001 2005-07-06
  • 打赏
  • 举报
回复
用表格模式来做:
JTable jTable1 = new JTable(new MyTableModel()) {
public TableCellRenderer getCellRenderer
(int row, int column) {
return mcr;
}
};

........................
class MyTableModel extends AbstractTableModel {

//实始化table数据
//列名
String[] columnNames = {"Name", "Age", "Sex"};

String[][] columnData = { {"Bob", "23", "M"}, {"Claire", "99", "F"},

//实现必须方法
public Object getValueAt(int row, int col) {
return columnData[row][col];
}

public String getColumnName(int col) {
return columnNames[col];
}

public int getColumnCount() {
return columnNames.length;
}

public int getRowCount() {
return columnData.length;
}
}
bigman_lfj 2005-06-29
  • 打赏
  • 举报
回复
大家看看啊。
bigman_lfj 2005-06-28
  • 打赏
  • 举报
回复
各位帮忙看看,3Q
bigman_lfj 2005-06-27
  • 打赏
  • 举报
回复
数据显示正常,列名不显示,

各位帮忙看看,谢谢

51,397

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧