jdk/src/share/classes/javax/swing/plaf/basic/BasicTableUI.java
changeset 25763 51d1f910f68d
parent 25565 ce603b34c98d
equal deleted inserted replaced
25762:c4a3548120c6 25763:51d1f910f68d
    62 //
    62 //
    63 // Instance Variables
    63 // Instance Variables
    64 //
    64 //
    65 
    65 
    66     // The JTable that is delegating the painting to this UI.
    66     // The JTable that is delegating the painting to this UI.
       
    67     /**
       
    68      * The instance of {@code JTable}.
       
    69      */
    67     protected JTable table;
    70     protected JTable table;
       
    71 
       
    72     /**
       
    73      * The instance of {@code CellRendererPane}.
       
    74      */
    68     protected CellRendererPane rendererPane;
    75     protected CellRendererPane rendererPane;
    69 
    76 
    70     // Listeners that are attached to the JTable
    77     /**
       
    78      * {@code KeyListener} that are attached to the {@code JTable}.
       
    79      */
    71     protected KeyListener keyListener;
    80     protected KeyListener keyListener;
       
    81 
       
    82     /**
       
    83      * {@code FocusListener} that are attached to the {@code JTable}.
       
    84      */
    72     protected FocusListener focusListener;
    85     protected FocusListener focusListener;
       
    86 
       
    87     /**
       
    88      * {@code MouseInputListener} that are attached to the {@code JTable}.
       
    89      */
    73     protected MouseInputListener mouseInputListener;
    90     protected MouseInputListener mouseInputListener;
    74 
    91 
    75     private Handler handler;
    92     private Handler handler;
    76 
    93 
    77     /**
    94     /**
  1348         }
  1365         }
  1349         return handler;
  1366         return handler;
  1350     }
  1367     }
  1351 
  1368 
  1352     /**
  1369     /**
  1353      * Creates the key listener for handling keyboard navigation in the JTable.
  1370      * Creates the key listener for handling keyboard navigation in the {@code JTable}.
       
  1371      *
       
  1372      * @return the key listener for handling keyboard navigation in the {@code JTable}
  1354      */
  1373      */
  1355     protected KeyListener createKeyListener() {
  1374     protected KeyListener createKeyListener() {
  1356         return null;
  1375         return null;
  1357     }
  1376     }
  1358 
  1377 
  1359     /**
  1378     /**
  1360      * Creates the focus listener for handling keyboard navigation in the JTable.
  1379      * Creates the focus listener for handling keyboard navigation in the {@code JTable}.
       
  1380      *
       
  1381      * @return the focus listener for handling keyboard navigation in the {@code JTable}
  1361      */
  1382      */
  1362     protected FocusListener createFocusListener() {
  1383     protected FocusListener createFocusListener() {
  1363         return getHandler();
  1384         return getHandler();
  1364     }
  1385     }
  1365 
  1386 
  1366     /**
  1387     /**
  1367      * Creates the mouse listener for the JTable.
  1388      * Creates the mouse listener for the {@code JTable}.
       
  1389      *
       
  1390      * @return the mouse listener for the {@code JTable}
  1368      */
  1391      */
  1369     protected MouseInputListener createMouseInputListener() {
  1392     protected MouseInputListener createMouseInputListener() {
  1370         return getHandler();
  1393         return getHandler();
  1371     }
  1394     }
  1372 
  1395 
  1373 //
  1396 //
  1374 //  The installation/uninstall procedures and support
  1397 //  The installation/uninstall procedures and support
  1375 //
  1398 //
  1376 
  1399 
       
  1400     /**
       
  1401      * Returns a new instance of {@code BasicTableUI}.
       
  1402      *
       
  1403      * @param c a component
       
  1404      * @return a new instance of {@code BasicTableUI}
       
  1405      */
  1377     public static ComponentUI createUI(JComponent c) {
  1406     public static ComponentUI createUI(JComponent c) {
  1378         return new BasicTableUI();
  1407         return new BasicTableUI();
  1379     }
  1408     }
  1380 
  1409 
  1381 //  Installation
  1410 //  Installation
  1614         table.remove(rendererPane);
  1643         table.remove(rendererPane);
  1615         rendererPane = null;
  1644         rendererPane = null;
  1616         table = null;
  1645         table = null;
  1617     }
  1646     }
  1618 
  1647 
       
  1648     /**
       
  1649      * Uninstalls default properties.
       
  1650      */
  1619     protected void uninstallDefaults() {
  1651     protected void uninstallDefaults() {
  1620         if (table.getTransferHandler() instanceof UIResource) {
  1652         if (table.getTransferHandler() instanceof UIResource) {
  1621             table.setTransferHandler(null);
  1653             table.setTransferHandler(null);
  1622         }
  1654         }
  1623     }
  1655     }
  1624 
  1656 
       
  1657     /**
       
  1658      * Unregisters listeners.
       
  1659      */
  1625     protected void uninstallListeners() {
  1660     protected void uninstallListeners() {
  1626         table.removeFocusListener(focusListener);
  1661         table.removeFocusListener(focusListener);
  1627         table.removeKeyListener(keyListener);
  1662         table.removeKeyListener(keyListener);
  1628         table.removeMouseListener(mouseInputListener);
  1663         table.removeMouseListener(mouseInputListener);
  1629         table.removeMouseMotionListener(mouseInputListener);
  1664         table.removeMouseMotionListener(mouseInputListener);
  1636         keyListener = null;
  1671         keyListener = null;
  1637         mouseInputListener = null;
  1672         mouseInputListener = null;
  1638         handler = null;
  1673         handler = null;
  1639     }
  1674     }
  1640 
  1675 
       
  1676     /**
       
  1677      * Unregisters keyboard actions.
       
  1678      */
  1641     protected void uninstallKeyboardActions() {
  1679     protected void uninstallKeyboardActions() {
  1642         SwingUtilities.replaceUIInputMap(table, JComponent.
  1680         SwingUtilities.replaceUIInputMap(table, JComponent.
  1643                                    WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
  1681                                    WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
  1644         SwingUtilities.replaceUIActionMap(table, null);
  1682         SwingUtilities.replaceUIActionMap(table, null);
  1645     }
  1683     }