问题
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