jscrollpane有jtable设置标题出现问题。。

hnlbhjbc 2014-03-27 11:55:24
Jscrollpane中加入Jtable
使用如下代码设置Jtable标头:
		
String columnName[] ={"入库编号","商品名称","单价","数量","单位","总额","供应商","入库去向","入库时间","车辆","司机","押运员"};
table = new JTable(){
public boolean isCellEditable(int row, int column) //重写了isCellEditable方法
{
return false;//表格不允许被编辑
}
};
dftm =(DefaultTableModel) table.getModel();
dftm.setColumnIdentifiers(columnName);//设置表头
scrollPane.setViewportView(table);

理论上应该是JTable表头显示在JSCrollPane标题的下方,但实际却显示在它上面,这是什么情况?????怎么解决
...全文
284 4 打赏 收藏 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
huntor 2014-03-29
  • 打赏
  • 举报
回复
To add a border around the main viewport, you can use setViewportBorder. (Of course, you can also add a border around the whole scroll pane using setBorder.)
hnlbhjbc 2014-03-29
  • 打赏
  • 举报
回复
what's up!!!
铁匠梁老师 2014-03-28
  • 打赏
  • 举报
回复
代码没贴完,border怎么设置的 GUI需要一步一步调整才能看到效果。
hnlbhjbc 2014-03-28
  • 打赏
  • 举报
回复

		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setViewportBorder(new TitledBorder(UIManager
				.getBorder("TitledBorder.border"),
				"\u5F85\u6DFB\u52A0\u9879\u76EE\uFF1A", TitledBorder.LEADING,
				TitledBorder.TOP, null, null));
		GridBagConstraints gbc_scrollPane = new GridBagConstraints();
		gbc_scrollPane.gridwidth = 4;
		gbc_scrollPane.insets = new Insets(0, 0, 5, 5);
		gbc_scrollPane.fill = GridBagConstraints.BOTH;
		gbc_scrollPane.gridx = 1;
		gbc_scrollPane.gridy = 1;
		contentPane.add(scrollPane, gbc_scrollPane);
这个是border的 设置。。

62,620

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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