Insert data into JTable from JTextField where JTableHeader is null

自古美人都是妖i 提交于 2020-05-16 19:11:41

问题


I am developing small desktop application in java and using the Netbeans IDE. I want read data from JTextField and insert it in the JTable character by character. But issue is that JTableHeader is not available(means that header null). Suggest me some way to resolve this problem.


回答1:


But issue is that JTableHeader is not available

The table header is a separate component and is only created when you add the table to a JScrollPane.

So instead of using code like:

panel.add( table );

The logic should be:

panel.add( new JScrollPane( table ) );

Now the table header can be displayed in the scroll pane.



来源:https://stackoverflow.com/questions/61076558/insert-data-into-jtable-from-jtextfield-where-jtableheader-is-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!