2817
2818 /* The focusGained() focusLost() methods run when the JList
2819 * focus changes.
2820 */
2821
2822 public void focusGained(FocusEvent e) {
2823 repaintCellFocus();
2824 }
2825
2826 public void focusLost(FocusEvent e) {
2827 repaintCellFocus();
2828 }
2829 }
2830
2831 private static int adjustIndex(int index, JList list) {
2832 return index < list.getModel().getSize() ? index : -1;
2833 }
2834
2835 private static final TransferHandler defaultTransferHandler = new ListTransferHandler();
2836
2837 static class ListTransferHandler extends TransferHandler implements UIResource {
2838
2839 /**
2840 * Create a Transferable to use as the source for a data transfer.
2841 *
2842 * @param c The component holding the data to be transfered. This
2843 * argument is provided to enable sharing of TransferHandlers by
2844 * multiple components.
2845 * @return The representation of the data to be transfered.
2846 *
2847 */
2848 protected Transferable createTransferable(JComponent c) {
2849 if (c instanceof JList) {
2850 JList list = (JList) c;
2851 Object[] values = list.getSelectedValues();
2852
2853 if (values == null || values.length == 0) {
2854 return null;
2855 }
2856
|
2817
2818 /* The focusGained() focusLost() methods run when the JList
2819 * focus changes.
2820 */
2821
2822 public void focusGained(FocusEvent e) {
2823 repaintCellFocus();
2824 }
2825
2826 public void focusLost(FocusEvent e) {
2827 repaintCellFocus();
2828 }
2829 }
2830
2831 private static int adjustIndex(int index, JList list) {
2832 return index < list.getModel().getSize() ? index : -1;
2833 }
2834
2835 private static final TransferHandler defaultTransferHandler = new ListTransferHandler();
2836
2837 @SuppressWarnings("serial") // Superclass is a JDK-implementation class
2838 static class ListTransferHandler extends TransferHandler implements UIResource {
2839
2840 /**
2841 * Create a Transferable to use as the source for a data transfer.
2842 *
2843 * @param c The component holding the data to be transfered. This
2844 * argument is provided to enable sharing of TransferHandlers by
2845 * multiple components.
2846 * @return The representation of the data to be transfered.
2847 *
2848 */
2849 protected Transferable createTransferable(JComponent c) {
2850 if (c instanceof JList) {
2851 JList list = (JList) c;
2852 Object[] values = list.getSelectedValues();
2853
2854 if (values == null || values.length == 0) {
2855 return null;
2856 }
2857
|