Skip to content

Commit 5864d7e

Browse files
committed
Method for retrieving a fixed part of table.
1 parent 319911c commit 5864d7e

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

src/org/quinto/swing/table/view/JBroTable.java

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -579,13 +579,7 @@ public void valueChanged( ListSelectionEvent e ) {
579579
* This method creates (if it doesn't exist yet) and returns a scroll pane that contains a viewport
580580
* with fixed columns. This scroll pane may have a null viewport if a model contains no visible
581581
* fixed columns.
582-
* <p>To obtain a left fixed table, use the following code:<br><br>
583-
* <code>
584-
* JViewport viewport = scrollPane.getRowHeader();<br>
585-
* if ( viewport != null ) {<br>
586-
* &nbsp;&nbsp;JBroTable fixed = ( JBroTable )viewport.getView();<br>
587-
* }
588-
* </code></p>
582+
* <p>To obtain a left fixed table, call {@link #getSlaveTable}.</p>
589583
* @return a scroll pane with a fixed left part (if required)
590584
*/
591585
public JScrollPane getScrollPane() {
@@ -633,9 +627,29 @@ private void tableStructureChanged() {
633627
}
634628
}
635629

636-
protected JBroTable getMasterTable() {
630+
/**
631+
* If this table is just a fixed (non-scrollable) part then this method would return main part.
632+
* @return main table for a fixed one, otherwise null
633+
*/
634+
public JBroTable getMasterTable() {
637635
return masterTable;
638636
}
637+
638+
/**
639+
* If this table has fixed columns then this method would return a fixed (non-scrollable) part.
640+
* @return fixed part for a main table, otherwise null
641+
*/
642+
public JBroTable getSlaveTable() {
643+
if ( getScrollPane() == null )
644+
return null;
645+
JViewport viewport = getScrollPane().getRowHeader();
646+
if ( viewport == null )
647+
return null;
648+
Component ret = viewport.getView();
649+
if ( !( ret instanceof JBroTable ) )
650+
return null;
651+
return ( JBroTable )ret;
652+
}
639653

640654
@Override
641655
public boolean hasFocus() {

0 commit comments

Comments
 (0)