jtable 不能正确显示标题

jtable 不能正确显示标题

ID:18414829

大小:99.00 KB

页数:32页

时间:2018-09-17

jtable 不能正确显示标题_第1页
jtable 不能正确显示标题_第2页
jtable 不能正确显示标题_第3页
jtable 不能正确显示标题_第4页
jtable 不能正确显示标题_第5页
资源描述:

《jtable 不能正确显示标题》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、JTable不能正确显示标题,关于这个,官方文档里面有说:JTable组件显示数据时,如果直接将其放置在Frame的contentPane中则表头一行会显示不出来,如果将其放置在JScrollPane中显示数据的话,表头会自动显示出来。引用Sun的原话为:It'seasytoputatableinascrollpane.Youneedjustoneortwolinesofcode:JScrollPanescrollPane=newJScrollPane(table);table.setPreferredScrollableViewportSize(newDimensio

2、n(500,70));Thescrollpaneautomaticallygetsthetable'sheader,whichdisplaysthecolumnnames,andputsitontopofthetable.Evenwhentheuserscrollsdown,thecolumnnamesremainvisibleatthetopoftheviewingarea.Thescrollpanealsotriestomakeitsviewingareathesameasthetable'spreferredviewingsize.Thepreviouscodes

3、nippetsetsthetable'spreferredviewingsizewiththesetPreferredScrollableViewportSizemethod.Ifyou'reusingatablewithoutascrollpane,thenyoumustgetthetableheadercomponentandplaceityourself.Forexample:container.setLayout(newBorderLayout());container.add(table.getTableHeader(),BorderLayout.PAGE_S

4、TART);container.add(table,BorderLayout.CENTER);在使用时要注意! 所以说使用JTable显示数据时,要将Table添加在JScrollPane里面; 但是我的代码里面还是显示不出来,开始检查原因:原来:如下添加table不行:scrollPanel.add(table);应该改为:scrollPanel.setViewportView(table);//解决显示表头问题:必须用这个但是,这样似乎还是不行,在检查,在尝试,终于:he"governingforthepeople","Nomattertheinterestsoft

5、hemasses"conceptunderstandingisnotinplace.Thespecificworktreatswiththedeployment,afewleadingcadrescomplainthatworkistoocomplicated,toomuchresponsibility,thepressureistoolarge,toomuchemphasisonthedifficultyofthework.Forexample,noncoalmine JTable不能正确显示标题,关于这个,官方文档里面有说:JTable组件显示数据时,如果直接将其放

6、置在Frame的contentPane中则表头一行会显示不出来,如果将其放置在JScrollPane中显示数据的话,表头会自动显示出来。引用Sun的原话为:It'seasytoputatableinascrollpane.Youneedjustoneortwolinesofcode:JScrollPanescrollPane=newJScrollPane(table);table.setPreferredScrollableViewportSize(newDimension(500,70));Thescrollpaneautomaticallygetsthetable'

7、sheader,whichdisplaysthecolumnnames,andputsitontopofthetable.Evenwhentheuserscrollsdown,thecolumnnamesremainvisibleatthetopoftheviewingarea.Thescrollpanealsotriestomakeitsviewingareathesameasthetable'spreferredviewingsize.Thepreviouscodesnippetsetsthetable'spreferredviewi

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。