Class SelectionSynchronizer

  • All Implemented Interfaces:
    java.util.EventListener, javax.swing.event.ListSelectionListener

    public class SelectionSynchronizer
    extends java.lang.Object
    implements javax.swing.event.ListSelectionListener
    Helper class to ensure that two (or more) JTables always have the same entries selected. The tables are usually displayed side-by-side.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Set<javax.swing.ListSelectionModel> participants  
      private boolean preventRecursion  
      private java.util.function.BiFunction<java.lang.Integer,​javax.swing.ListSelectionModel,​java.util.stream.IntStream> selectionIndexMapper  
    • Constructor Summary

      Constructors 
      Constructor Description
      SelectionSynchronizer()
      Constructs a new SelectionSynchronizer.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void participateInSynchronizedSelection​(javax.swing.ListSelectionModel model)
      Add ListSelectionModel of the table to participate in selection synchronization.
      (package private) void setSelectionIndexMapper​(java.util.function.BiFunction<java.lang.Integer,​javax.swing.ListSelectionModel,​java.util.stream.IntStream> selectionIndexMapper)  
      void valueChanged​(javax.swing.event.ListSelectionEvent e)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • participants

        private final java.util.Set<javax.swing.ListSelectionModel> participants
      • selectionIndexMapper

        private java.util.function.BiFunction<java.lang.Integer,​javax.swing.ListSelectionModel,​java.util.stream.IntStream> selectionIndexMapper
    • Method Detail

      • participateInSynchronizedSelection

        public void participateInSynchronizedSelection​(javax.swing.ListSelectionModel model)
        Add ListSelectionModel of the table to participate in selection synchronization. Call this method for all tables that should have their selection synchronized.
        Parameters:
        model - the selection model of the table
      • setSelectionIndexMapper

        void setSelectionIndexMapper​(java.util.function.BiFunction<java.lang.Integer,​javax.swing.ListSelectionModel,​java.util.stream.IntStream> selectionIndexMapper)
      • valueChanged

        public void valueChanged​(javax.swing.event.ListSelectionEvent e)
        Specified by:
        valueChanged in interface javax.swing.event.ListSelectionListener