« Return to Thread: Track property selection in property sheet

Re: Track property selection in property sheet

by Tim Boudreau :: Rate this Message:

Reply to Author | View in Thread

Vadeg wrote:
Code:
    //Package private for unit tests

    SheetTable table = new SheetTable();

    PSheet psheet = new PSheet();
You would need to do somthing like

JTable findTable (Container startingContainer) {
   if (startingContainer instanceof JTable) {
       return (JTable) startingContainer;
   }
   for (Component c : startingContainer.getChildren() {
         if (c instanceof Container) {
             JTable result = findTable ((Container)c));
             if (result != null) return result;
          }  
   }
}

then listen on the selection model returned by the JTable's getSelectionModel() method.

Bear in mind, this approach is not highly recommended, since there is no official API for tracking selection in the property sheet.  It would be better to have a supported API for it.  At the same time, this should work for the forseeable future.

-Tim

 « Return to Thread: Track property selection in property sheet