Using an empty column as a divider in a JTable

后端 未结 4 1105
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 13:17

I\'m trying to use an empty column as a divider between pairs of columns in a JTable. Here\'s a picture and code for what I have so far. I know I can change the

4条回答
  •  悲&欢浪女
    2020-11-29 13:58

    On problem with this approach it that the user will need to "tab over" the divider column. You could use the Table Tabbing suggestion to make it more user friendly.

    Or if tabbing between the two tables isn't important, then maybe you can use use two tables and put whatever divider you want betweeen the two. The selection model can shared if required.

    Edit:

    As I suggested above sharing models is easier than writing custom listeners. To keep the scrolling in sync the code would be:

    jspa.getVerticalScrollBar().setModel( jspb.getVerticalScrollBar().getModel() );
    

    You can also do the same with the selection model so that highlighting of rows is in sync.

提交回复
热议问题