Java Code Examples for sun.swing.SwingUtilities2#setLeadAnchorWithoutSelection()
The following examples show how to use
sun.swing.SwingUtilities2#setLeadAnchorWithoutSelection() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DarkListUIBridge.java From darklaf with MIT License | 5 votes |
private void selectAll(final JList<?> list) { int size = list.getModel().getSize(); if (size > 0) { ListSelectionModel lsm = list.getSelectionModel(); int lead = adjustIndex(lsm.getLeadSelectionIndex(), list); if (lsm.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) { if (lead == -1) { int min = adjustIndex(list.getMinSelectionIndex(), list); lead = (min == -1 ? 0 : min); } list.setSelectionInterval(lead, lead); list.ensureIndexIsVisible(lead); } else { list.setValueIsAdjusting(true); int anchor = adjustIndex(lsm.getAnchorSelectionIndex(), list); list.setSelectionInterval(0, size - 1); // this is done to restore the anchor and lead SwingUtilities2.setLeadAnchorWithoutSelection(lsm, anchor, lead); list.setValueIsAdjusting(false); } } }
Example 2
Source File: BasicListUI.java From hottub with GNU General Public License v2.0 | 5 votes |
private void selectAll(JList list) { int size = list.getModel().getSize(); if (size > 0) { ListSelectionModel lsm = list.getSelectionModel(); int lead = adjustIndex(lsm.getLeadSelectionIndex(), list); if (lsm.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) { if (lead == -1) { int min = adjustIndex(list.getMinSelectionIndex(), list); lead = (min == -1 ? 0 : min); } list.setSelectionInterval(lead, lead); list.ensureIndexIsVisible(lead); } else { list.setValueIsAdjusting(true); int anchor = adjustIndex(lsm.getAnchorSelectionIndex(), list); list.setSelectionInterval(0, size - 1); // this is done to restore the anchor and lead SwingUtilities2.setLeadAnchorWithoutSelection(lsm, anchor, lead); list.setValueIsAdjusting(false); } } }
Example 3
Source File: BasicListUI.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private void selectAll(JList list) { int size = list.getModel().getSize(); if (size > 0) { ListSelectionModel lsm = list.getSelectionModel(); int lead = adjustIndex(lsm.getLeadSelectionIndex(), list); if (lsm.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) { if (lead == -1) { int min = adjustIndex(list.getMinSelectionIndex(), list); lead = (min == -1 ? 0 : min); } list.setSelectionInterval(lead, lead); list.ensureIndexIsVisible(lead); } else { list.setValueIsAdjusting(true); int anchor = adjustIndex(lsm.getAnchorSelectionIndex(), list); list.setSelectionInterval(0, size - 1); // this is done to restore the anchor and lead SwingUtilities2.setLeadAnchorWithoutSelection(lsm, anchor, lead); list.setValueIsAdjusting(false); } } }
Example 4
Source File: BasicListUI.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void selectAll(JList list) { int size = list.getModel().getSize(); if (size > 0) { ListSelectionModel lsm = list.getSelectionModel(); int lead = adjustIndex(lsm.getLeadSelectionIndex(), list); if (lsm.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) { if (lead == -1) { int min = adjustIndex(list.getMinSelectionIndex(), list); lead = (min == -1 ? 0 : min); } list.setSelectionInterval(lead, lead); list.ensureIndexIsVisible(lead); } else { list.setValueIsAdjusting(true); int anchor = adjustIndex(lsm.getAnchorSelectionIndex(), list); list.setSelectionInterval(0, size - 1); // this is done to restore the anchor and lead SwingUtilities2.setLeadAnchorWithoutSelection(lsm, anchor, lead); list.setValueIsAdjusting(false); } } }
Example 5
Source File: BasicListUI.java From Java8CN with Apache License 2.0 | 5 votes |
private void selectAll(JList list) { int size = list.getModel().getSize(); if (size > 0) { ListSelectionModel lsm = list.getSelectionModel(); int lead = adjustIndex(lsm.getLeadSelectionIndex(), list); if (lsm.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) { if (lead == -1) { int min = adjustIndex(list.getMinSelectionIndex(), list); lead = (min == -1 ? 0 : min); } list.setSelectionInterval(lead, lead); list.ensureIndexIsVisible(lead); } else { list.setValueIsAdjusting(true); int anchor = adjustIndex(lsm.getAnchorSelectionIndex(), list); list.setSelectionInterval(0, size - 1); // this is done to restore the anchor and lead SwingUtilities2.setLeadAnchorWithoutSelection(lsm, anchor, lead); list.setValueIsAdjusting(false); } } }
Example 6
Source File: BasicListUI.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private void selectAll(JList list) { int size = list.getModel().getSize(); if (size > 0) { ListSelectionModel lsm = list.getSelectionModel(); int lead = adjustIndex(lsm.getLeadSelectionIndex(), list); if (lsm.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) { if (lead == -1) { int min = adjustIndex(list.getMinSelectionIndex(), list); lead = (min == -1 ? 0 : min); } list.setSelectionInterval(lead, lead); list.ensureIndexIsVisible(lead); } else { list.setValueIsAdjusting(true); int anchor = adjustIndex(lsm.getAnchorSelectionIndex(), list); list.setSelectionInterval(0, size - 1); // this is done to restore the anchor and lead SwingUtilities2.setLeadAnchorWithoutSelection(lsm, anchor, lead); list.setValueIsAdjusting(false); } } }
Example 7
Source File: BasicListUI.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private void selectAll(JList list) { int size = list.getModel().getSize(); if (size > 0) { ListSelectionModel lsm = list.getSelectionModel(); int lead = adjustIndex(lsm.getLeadSelectionIndex(), list); if (lsm.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) { if (lead == -1) { int min = adjustIndex(list.getMinSelectionIndex(), list); lead = (min == -1 ? 0 : min); } list.setSelectionInterval(lead, lead); list.ensureIndexIsVisible(lead); } else { list.setValueIsAdjusting(true); int anchor = adjustIndex(lsm.getAnchorSelectionIndex(), list); list.setSelectionInterval(0, size - 1); // this is done to restore the anchor and lead SwingUtilities2.setLeadAnchorWithoutSelection(lsm, anchor, lead); list.setValueIsAdjusting(false); } } }
Example 8
Source File: BasicListUI.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private void selectAll(JList list) { int size = list.getModel().getSize(); if (size > 0) { ListSelectionModel lsm = list.getSelectionModel(); int lead = adjustIndex(lsm.getLeadSelectionIndex(), list); if (lsm.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) { if (lead == -1) { int min = adjustIndex(list.getMinSelectionIndex(), list); lead = (min == -1 ? 0 : min); } list.setSelectionInterval(lead, lead); list.ensureIndexIsVisible(lead); } else { list.setValueIsAdjusting(true); int anchor = adjustIndex(lsm.getAnchorSelectionIndex(), list); list.setSelectionInterval(0, size - 1); // this is done to restore the anchor and lead SwingUtilities2.setLeadAnchorWithoutSelection(lsm, anchor, lead); list.setValueIsAdjusting(false); } } }
Example 9
Source File: JList.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Called to set or clear the drop location during a DnD operation. * In some cases, the component may need to use it's internal selection * temporarily to indicate the drop location. To help facilitate this, * this method returns and accepts as a parameter a state object. * This state object can be used to store, and later restore, the selection * state. Whatever this method returns will be passed back to it in * future calls, as the state parameter. If it wants the DnD system to * continue storing the same state, it must pass it back every time. * Here's how this is used: * <p> * Let's say that on the first call to this method the component decides * to save some state (because it is about to use the selection to show * a drop index). It can return a state object to the caller encapsulating * any saved selection state. On a second call, let's say the drop location * is being changed to something else. The component doesn't need to * restore anything yet, so it simply passes back the same state object * to have the DnD system continue storing it. Finally, let's say this * method is messaged with <code>null</code>. This means DnD * is finished with this component for now, meaning it should restore * state. At this point, it can use the state parameter to restore * said state, and of course return <code>null</code> since there's * no longer anything to store. * * @param location the drop location (as calculated by * <code>dropLocationForPoint</code>) or <code>null</code> * if there's no longer a valid drop location * @param state the state object saved earlier for this component, * or <code>null</code> * @param forDrop whether or not the method is being called because an * actual drop occurred * @return any saved state for this component, or <code>null</code> if none */ Object setDropLocation(TransferHandler.DropLocation location, Object state, boolean forDrop) { Object retVal = null; DropLocation listLocation = (DropLocation)location; if (dropMode == DropMode.USE_SELECTION) { if (listLocation == null) { if (!forDrop && state != null) { setSelectedIndices(((int[][])state)[0]); int anchor = ((int[][])state)[1][0]; int lead = ((int[][])state)[1][1]; SwingUtilities2.setLeadAnchorWithoutSelection( getSelectionModel(), lead, anchor); } } else { if (dropLocation == null) { int[] inds = getSelectedIndices(); retVal = new int[][] {inds, {getAnchorSelectionIndex(), getLeadSelectionIndex()}}; } else { retVal = state; } int index = listLocation.getIndex(); if (index == -1) { clearSelection(); getSelectionModel().setAnchorSelectionIndex(-1); getSelectionModel().setLeadSelectionIndex(-1); } else { setSelectionInterval(index, index); } } } DropLocation old = dropLocation; dropLocation = listLocation; firePropertyChange("dropLocation", old, dropLocation); return retVal; }
Example 10
Source File: JList.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Called to set or clear the drop location during a DnD operation. * In some cases, the component may need to use it's internal selection * temporarily to indicate the drop location. To help facilitate this, * this method returns and accepts as a parameter a state object. * This state object can be used to store, and later restore, the selection * state. Whatever this method returns will be passed back to it in * future calls, as the state parameter. If it wants the DnD system to * continue storing the same state, it must pass it back every time. * Here's how this is used: * <p> * Let's say that on the first call to this method the component decides * to save some state (because it is about to use the selection to show * a drop index). It can return a state object to the caller encapsulating * any saved selection state. On a second call, let's say the drop location * is being changed to something else. The component doesn't need to * restore anything yet, so it simply passes back the same state object * to have the DnD system continue storing it. Finally, let's say this * method is messaged with <code>null</code>. This means DnD * is finished with this component for now, meaning it should restore * state. At this point, it can use the state parameter to restore * said state, and of course return <code>null</code> since there's * no longer anything to store. * * @param location the drop location (as calculated by * <code>dropLocationForPoint</code>) or <code>null</code> * if there's no longer a valid drop location * @param state the state object saved earlier for this component, * or <code>null</code> * @param forDrop whether or not the method is being called because an * actual drop occurred * @return any saved state for this component, or <code>null</code> if none */ Object setDropLocation(TransferHandler.DropLocation location, Object state, boolean forDrop) { Object retVal = null; DropLocation listLocation = (DropLocation)location; if (dropMode == DropMode.USE_SELECTION) { if (listLocation == null) { if (!forDrop && state != null) { setSelectedIndices(((int[][])state)[0]); int anchor = ((int[][])state)[1][0]; int lead = ((int[][])state)[1][1]; SwingUtilities2.setLeadAnchorWithoutSelection( getSelectionModel(), lead, anchor); } } else { if (dropLocation == null) { int[] inds = getSelectedIndices(); retVal = new int[][] {inds, {getAnchorSelectionIndex(), getLeadSelectionIndex()}}; } else { retVal = state; } int index = listLocation.getIndex(); if (index == -1) { clearSelection(); getSelectionModel().setAnchorSelectionIndex(-1); getSelectionModel().setLeadSelectionIndex(-1); } else { setSelectionInterval(index, index); } } } DropLocation old = dropLocation; dropLocation = listLocation; firePropertyChange("dropLocation", old, dropLocation); return retVal; }
Example 11
Source File: JList.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Called to set or clear the drop location during a DnD operation. * In some cases, the component may need to use it's internal selection * temporarily to indicate the drop location. To help facilitate this, * this method returns and accepts as a parameter a state object. * This state object can be used to store, and later restore, the selection * state. Whatever this method returns will be passed back to it in * future calls, as the state parameter. If it wants the DnD system to * continue storing the same state, it must pass it back every time. * Here's how this is used: * <p> * Let's say that on the first call to this method the component decides * to save some state (because it is about to use the selection to show * a drop index). It can return a state object to the caller encapsulating * any saved selection state. On a second call, let's say the drop location * is being changed to something else. The component doesn't need to * restore anything yet, so it simply passes back the same state object * to have the DnD system continue storing it. Finally, let's say this * method is messaged with <code>null</code>. This means DnD * is finished with this component for now, meaning it should restore * state. At this point, it can use the state parameter to restore * said state, and of course return <code>null</code> since there's * no longer anything to store. * * @param location the drop location (as calculated by * <code>dropLocationForPoint</code>) or <code>null</code> * if there's no longer a valid drop location * @param state the state object saved earlier for this component, * or <code>null</code> * @param forDrop whether or not the method is being called because an * actual drop occurred * @return any saved state for this component, or <code>null</code> if none */ Object setDropLocation(TransferHandler.DropLocation location, Object state, boolean forDrop) { Object retVal = null; DropLocation listLocation = (DropLocation)location; if (dropMode == DropMode.USE_SELECTION) { if (listLocation == null) { if (!forDrop && state != null) { setSelectedIndices(((int[][])state)[0]); int anchor = ((int[][])state)[1][0]; int lead = ((int[][])state)[1][1]; SwingUtilities2.setLeadAnchorWithoutSelection( getSelectionModel(), lead, anchor); } } else { if (dropLocation == null) { int[] inds = getSelectedIndices(); retVal = new int[][] {inds, {getAnchorSelectionIndex(), getLeadSelectionIndex()}}; } else { retVal = state; } int index = listLocation.getIndex(); if (index == -1) { clearSelection(); getSelectionModel().setAnchorSelectionIndex(-1); getSelectionModel().setLeadSelectionIndex(-1); } else { setSelectionInterval(index, index); } } } DropLocation old = dropLocation; dropLocation = listLocation; firePropertyChange("dropLocation", old, dropLocation); return retVal; }
Example 12
Source File: JList.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * Called to set or clear the drop location during a DnD operation. * In some cases, the component may need to use it's internal selection * temporarily to indicate the drop location. To help facilitate this, * this method returns and accepts as a parameter a state object. * This state object can be used to store, and later restore, the selection * state. Whatever this method returns will be passed back to it in * future calls, as the state parameter. If it wants the DnD system to * continue storing the same state, it must pass it back every time. * Here's how this is used: * <p> * Let's say that on the first call to this method the component decides * to save some state (because it is about to use the selection to show * a drop index). It can return a state object to the caller encapsulating * any saved selection state. On a second call, let's say the drop location * is being changed to something else. The component doesn't need to * restore anything yet, so it simply passes back the same state object * to have the DnD system continue storing it. Finally, let's say this * method is messaged with <code>null</code>. This means DnD * is finished with this component for now, meaning it should restore * state. At this point, it can use the state parameter to restore * said state, and of course return <code>null</code> since there's * no longer anything to store. * * @param location the drop location (as calculated by * <code>dropLocationForPoint</code>) or <code>null</code> * if there's no longer a valid drop location * @param state the state object saved earlier for this component, * or <code>null</code> * @param forDrop whether or not the method is being called because an * actual drop occurred * @return any saved state for this component, or <code>null</code> if none */ Object setDropLocation(TransferHandler.DropLocation location, Object state, boolean forDrop) { Object retVal = null; DropLocation listLocation = (DropLocation)location; if (dropMode == DropMode.USE_SELECTION) { if (listLocation == null) { if (!forDrop && state != null) { setSelectedIndices(((int[][])state)[0]); int anchor = ((int[][])state)[1][0]; int lead = ((int[][])state)[1][1]; SwingUtilities2.setLeadAnchorWithoutSelection( getSelectionModel(), lead, anchor); } } else { if (dropLocation == null) { int[] inds = getSelectedIndices(); retVal = new int[][] {inds, {getAnchorSelectionIndex(), getLeadSelectionIndex()}}; } else { retVal = state; } int index = listLocation.getIndex(); if (index == -1) { clearSelection(); getSelectionModel().setAnchorSelectionIndex(-1); getSelectionModel().setLeadSelectionIndex(-1); } else { setSelectionInterval(index, index); } } } DropLocation old = dropLocation; dropLocation = listLocation; firePropertyChange("dropLocation", old, dropLocation); return retVal; }
Example 13
Source File: JList.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Called to set or clear the drop location during a DnD operation. * In some cases, the component may need to use it's internal selection * temporarily to indicate the drop location. To help facilitate this, * this method returns and accepts as a parameter a state object. * This state object can be used to store, and later restore, the selection * state. Whatever this method returns will be passed back to it in * future calls, as the state parameter. If it wants the DnD system to * continue storing the same state, it must pass it back every time. * Here's how this is used: * <p> * Let's say that on the first call to this method the component decides * to save some state (because it is about to use the selection to show * a drop index). It can return a state object to the caller encapsulating * any saved selection state. On a second call, let's say the drop location * is being changed to something else. The component doesn't need to * restore anything yet, so it simply passes back the same state object * to have the DnD system continue storing it. Finally, let's say this * method is messaged with <code>null</code>. This means DnD * is finished with this component for now, meaning it should restore * state. At this point, it can use the state parameter to restore * said state, and of course return <code>null</code> since there's * no longer anything to store. * * @param location the drop location (as calculated by * <code>dropLocationForPoint</code>) or <code>null</code> * if there's no longer a valid drop location * @param state the state object saved earlier for this component, * or <code>null</code> * @param forDrop whether or not the method is being called because an * actual drop occurred * @return any saved state for this component, or <code>null</code> if none */ Object setDropLocation(TransferHandler.DropLocation location, Object state, boolean forDrop) { Object retVal = null; DropLocation listLocation = (DropLocation)location; if (dropMode == DropMode.USE_SELECTION) { if (listLocation == null) { if (!forDrop && state != null) { setSelectedIndices(((int[][])state)[0]); int anchor = ((int[][])state)[1][0]; int lead = ((int[][])state)[1][1]; SwingUtilities2.setLeadAnchorWithoutSelection( getSelectionModel(), lead, anchor); } } else { if (dropLocation == null) { int[] inds = getSelectedIndices(); retVal = new int[][] {inds, {getAnchorSelectionIndex(), getLeadSelectionIndex()}}; } else { retVal = state; } int index = listLocation.getIndex(); if (index == -1) { clearSelection(); getSelectionModel().setAnchorSelectionIndex(-1); getSelectionModel().setLeadSelectionIndex(-1); } else { setSelectionInterval(index, index); } } } DropLocation old = dropLocation; dropLocation = listLocation; firePropertyChange("dropLocation", old, dropLocation); return retVal; }
Example 14
Source File: JList.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Called to set or clear the drop location during a DnD operation. * In some cases, the component may need to use it's internal selection * temporarily to indicate the drop location. To help facilitate this, * this method returns and accepts as a parameter a state object. * This state object can be used to store, and later restore, the selection * state. Whatever this method returns will be passed back to it in * future calls, as the state parameter. If it wants the DnD system to * continue storing the same state, it must pass it back every time. * Here's how this is used: * <p> * Let's say that on the first call to this method the component decides * to save some state (because it is about to use the selection to show * a drop index). It can return a state object to the caller encapsulating * any saved selection state. On a second call, let's say the drop location * is being changed to something else. The component doesn't need to * restore anything yet, so it simply passes back the same state object * to have the DnD system continue storing it. Finally, let's say this * method is messaged with <code>null</code>. This means DnD * is finished with this component for now, meaning it should restore * state. At this point, it can use the state parameter to restore * said state, and of course return <code>null</code> since there's * no longer anything to store. * * @param location the drop location (as calculated by * <code>dropLocationForPoint</code>) or <code>null</code> * if there's no longer a valid drop location * @param state the state object saved earlier for this component, * or <code>null</code> * @param forDrop whether or not the method is being called because an * actual drop occurred * @return any saved state for this component, or <code>null</code> if none */ Object setDropLocation(TransferHandler.DropLocation location, Object state, boolean forDrop) { Object retVal = null; DropLocation listLocation = (DropLocation)location; if (dropMode == DropMode.USE_SELECTION) { if (listLocation == null) { if (!forDrop && state != null) { setSelectedIndices(((int[][])state)[0]); int anchor = ((int[][])state)[1][0]; int lead = ((int[][])state)[1][1]; SwingUtilities2.setLeadAnchorWithoutSelection( getSelectionModel(), lead, anchor); } } else { if (dropLocation == null) { int[] inds = getSelectedIndices(); retVal = new int[][] {inds, {getAnchorSelectionIndex(), getLeadSelectionIndex()}}; } else { retVal = state; } int index = listLocation.getIndex(); if (index == -1) { clearSelection(); getSelectionModel().setAnchorSelectionIndex(-1); getSelectionModel().setLeadSelectionIndex(-1); } else { setSelectionInterval(index, index); } } } DropLocation old = dropLocation; dropLocation = listLocation; firePropertyChange("dropLocation", old, dropLocation); return retVal; }
Example 15
Source File: JList.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * Called to set or clear the drop location during a DnD operation. * In some cases, the component may need to use it's internal selection * temporarily to indicate the drop location. To help facilitate this, * this method returns and accepts as a parameter a state object. * This state object can be used to store, and later restore, the selection * state. Whatever this method returns will be passed back to it in * future calls, as the state parameter. If it wants the DnD system to * continue storing the same state, it must pass it back every time. * Here's how this is used: * <p> * Let's say that on the first call to this method the component decides * to save some state (because it is about to use the selection to show * a drop index). It can return a state object to the caller encapsulating * any saved selection state. On a second call, let's say the drop location * is being changed to something else. The component doesn't need to * restore anything yet, so it simply passes back the same state object * to have the DnD system continue storing it. Finally, let's say this * method is messaged with <code>null</code>. This means DnD * is finished with this component for now, meaning it should restore * state. At this point, it can use the state parameter to restore * said state, and of course return <code>null</code> since there's * no longer anything to store. * * @param location the drop location (as calculated by * <code>dropLocationForPoint</code>) or <code>null</code> * if there's no longer a valid drop location * @param state the state object saved earlier for this component, * or <code>null</code> * @param forDrop whether or not the method is being called because an * actual drop occurred * @return any saved state for this component, or <code>null</code> if none */ Object setDropLocation(TransferHandler.DropLocation location, Object state, boolean forDrop) { Object retVal = null; DropLocation listLocation = (DropLocation)location; if (dropMode == DropMode.USE_SELECTION) { if (listLocation == null) { if (!forDrop && state != null) { setSelectedIndices(((int[][])state)[0]); int anchor = ((int[][])state)[1][0]; int lead = ((int[][])state)[1][1]; SwingUtilities2.setLeadAnchorWithoutSelection( getSelectionModel(), lead, anchor); } } else { if (dropLocation == null) { int[] inds = getSelectedIndices(); retVal = new int[][] {inds, {getAnchorSelectionIndex(), getLeadSelectionIndex()}}; } else { retVal = state; } int index = listLocation.getIndex(); if (index == -1) { clearSelection(); getSelectionModel().setAnchorSelectionIndex(-1); getSelectionModel().setLeadSelectionIndex(-1); } else { setSelectionInterval(index, index); } } } DropLocation old = dropLocation; dropLocation = listLocation; firePropertyChange("dropLocation", old, dropLocation); return retVal; }
Example 16
Source File: JList.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Called to set or clear the drop location during a DnD operation. * In some cases, the component may need to use it's internal selection * temporarily to indicate the drop location. To help facilitate this, * this method returns and accepts as a parameter a state object. * This state object can be used to store, and later restore, the selection * state. Whatever this method returns will be passed back to it in * future calls, as the state parameter. If it wants the DnD system to * continue storing the same state, it must pass it back every time. * Here's how this is used: * <p> * Let's say that on the first call to this method the component decides * to save some state (because it is about to use the selection to show * a drop index). It can return a state object to the caller encapsulating * any saved selection state. On a second call, let's say the drop location * is being changed to something else. The component doesn't need to * restore anything yet, so it simply passes back the same state object * to have the DnD system continue storing it. Finally, let's say this * method is messaged with <code>null</code>. This means DnD * is finished with this component for now, meaning it should restore * state. At this point, it can use the state parameter to restore * said state, and of course return <code>null</code> since there's * no longer anything to store. * * @param location the drop location (as calculated by * <code>dropLocationForPoint</code>) or <code>null</code> * if there's no longer a valid drop location * @param state the state object saved earlier for this component, * or <code>null</code> * @param forDrop whether or not the method is being called because an * actual drop occurred * @return any saved state for this component, or <code>null</code> if none */ Object setDropLocation(TransferHandler.DropLocation location, Object state, boolean forDrop) { Object retVal = null; DropLocation listLocation = (DropLocation)location; if (dropMode == DropMode.USE_SELECTION) { if (listLocation == null) { if (!forDrop && state != null) { setSelectedIndices(((int[][])state)[0]); int anchor = ((int[][])state)[1][0]; int lead = ((int[][])state)[1][1]; SwingUtilities2.setLeadAnchorWithoutSelection( getSelectionModel(), lead, anchor); } } else { if (dropLocation == null) { int[] inds = getSelectedIndices(); retVal = new int[][] {inds, {getAnchorSelectionIndex(), getLeadSelectionIndex()}}; } else { retVal = state; } int index = listLocation.getIndex(); if (index == -1) { clearSelection(); getSelectionModel().setAnchorSelectionIndex(-1); getSelectionModel().setLeadSelectionIndex(-1); } else { setSelectionInterval(index, index); } } } DropLocation old = dropLocation; dropLocation = listLocation; firePropertyChange("dropLocation", old, dropLocation); return retVal; }
Example 17
Source File: JList.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Called to set or clear the drop location during a DnD operation. * In some cases, the component may need to use it's internal selection * temporarily to indicate the drop location. To help facilitate this, * this method returns and accepts as a parameter a state object. * This state object can be used to store, and later restore, the selection * state. Whatever this method returns will be passed back to it in * future calls, as the state parameter. If it wants the DnD system to * continue storing the same state, it must pass it back every time. * Here's how this is used: * <p> * Let's say that on the first call to this method the component decides * to save some state (because it is about to use the selection to show * a drop index). It can return a state object to the caller encapsulating * any saved selection state. On a second call, let's say the drop location * is being changed to something else. The component doesn't need to * restore anything yet, so it simply passes back the same state object * to have the DnD system continue storing it. Finally, let's say this * method is messaged with <code>null</code>. This means DnD * is finished with this component for now, meaning it should restore * state. At this point, it can use the state parameter to restore * said state, and of course return <code>null</code> since there's * no longer anything to store. * * @param location the drop location (as calculated by * <code>dropLocationForPoint</code>) or <code>null</code> * if there's no longer a valid drop location * @param state the state object saved earlier for this component, * or <code>null</code> * @param forDrop whether or not the method is being called because an * actual drop occurred * @return any saved state for this component, or <code>null</code> if none */ Object setDropLocation(TransferHandler.DropLocation location, Object state, boolean forDrop) { Object retVal = null; DropLocation listLocation = (DropLocation)location; if (dropMode == DropMode.USE_SELECTION) { if (listLocation == null) { if (!forDrop && state != null) { setSelectedIndices(((int[][])state)[0]); int anchor = ((int[][])state)[1][0]; int lead = ((int[][])state)[1][1]; SwingUtilities2.setLeadAnchorWithoutSelection( getSelectionModel(), lead, anchor); } } else { if (dropLocation == null) { int[] inds = getSelectedIndices(); retVal = new int[][] {inds, {getAnchorSelectionIndex(), getLeadSelectionIndex()}}; } else { retVal = state; } int index = listLocation.getIndex(); if (index == -1) { clearSelection(); getSelectionModel().setAnchorSelectionIndex(-1); getSelectionModel().setLeadSelectionIndex(-1); } else { setSelectionInterval(index, index); } } } DropLocation old = dropLocation; dropLocation = listLocation; firePropertyChange("dropLocation", old, dropLocation); return retVal; }
Example 18
Source File: JList.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
/** * Called to set or clear the drop location during a DnD operation. * In some cases, the component may need to use it's internal selection * temporarily to indicate the drop location. To help facilitate this, * this method returns and accepts as a parameter a state object. * This state object can be used to store, and later restore, the selection * state. Whatever this method returns will be passed back to it in * future calls, as the state parameter. If it wants the DnD system to * continue storing the same state, it must pass it back every time. * Here's how this is used: * <p> * Let's say that on the first call to this method the component decides * to save some state (because it is about to use the selection to show * a drop index). It can return a state object to the caller encapsulating * any saved selection state. On a second call, let's say the drop location * is being changed to something else. The component doesn't need to * restore anything yet, so it simply passes back the same state object * to have the DnD system continue storing it. Finally, let's say this * method is messaged with <code>null</code>. This means DnD * is finished with this component for now, meaning it should restore * state. At this point, it can use the state parameter to restore * said state, and of course return <code>null</code> since there's * no longer anything to store. * * @param location the drop location (as calculated by * <code>dropLocationForPoint</code>) or <code>null</code> * if there's no longer a valid drop location * @param state the state object saved earlier for this component, * or <code>null</code> * @param forDrop whether or not the method is being called because an * actual drop occurred * @return any saved state for this component, or <code>null</code> if none */ Object setDropLocation(TransferHandler.DropLocation location, Object state, boolean forDrop) { Object retVal = null; DropLocation listLocation = (DropLocation)location; if (dropMode == DropMode.USE_SELECTION) { if (listLocation == null) { if (!forDrop && state != null) { setSelectedIndices(((int[][])state)[0]); int anchor = ((int[][])state)[1][0]; int lead = ((int[][])state)[1][1]; SwingUtilities2.setLeadAnchorWithoutSelection( getSelectionModel(), lead, anchor); } } else { if (dropLocation == null) { int[] inds = getSelectedIndices(); retVal = new int[][] {inds, {getAnchorSelectionIndex(), getLeadSelectionIndex()}}; } else { retVal = state; } int index = listLocation.getIndex(); if (index == -1) { clearSelection(); getSelectionModel().setAnchorSelectionIndex(-1); getSelectionModel().setLeadSelectionIndex(-1); } else { setSelectionInterval(index, index); } } } DropLocation old = dropLocation; dropLocation = listLocation; firePropertyChange("dropLocation", old, dropLocation); return retVal; }
Example 19
Source File: JList.java From Java8CN with Apache License 2.0 | 4 votes |
/** * Called to set or clear the drop location during a DnD operation. * In some cases, the component may need to use it's internal selection * temporarily to indicate the drop location. To help facilitate this, * this method returns and accepts as a parameter a state object. * This state object can be used to store, and later restore, the selection * state. Whatever this method returns will be passed back to it in * future calls, as the state parameter. If it wants the DnD system to * continue storing the same state, it must pass it back every time. * Here's how this is used: * <p> * Let's say that on the first call to this method the component decides * to save some state (because it is about to use the selection to show * a drop index). It can return a state object to the caller encapsulating * any saved selection state. On a second call, let's say the drop location * is being changed to something else. The component doesn't need to * restore anything yet, so it simply passes back the same state object * to have the DnD system continue storing it. Finally, let's say this * method is messaged with <code>null</code>. This means DnD * is finished with this component for now, meaning it should restore * state. At this point, it can use the state parameter to restore * said state, and of course return <code>null</code> since there's * no longer anything to store. * * @param location the drop location (as calculated by * <code>dropLocationForPoint</code>) or <code>null</code> * if there's no longer a valid drop location * @param state the state object saved earlier for this component, * or <code>null</code> * @param forDrop whether or not the method is being called because an * actual drop occurred * @return any saved state for this component, or <code>null</code> if none */ Object setDropLocation(TransferHandler.DropLocation location, Object state, boolean forDrop) { Object retVal = null; DropLocation listLocation = (DropLocation)location; if (dropMode == DropMode.USE_SELECTION) { if (listLocation == null) { if (!forDrop && state != null) { setSelectedIndices(((int[][])state)[0]); int anchor = ((int[][])state)[1][0]; int lead = ((int[][])state)[1][1]; SwingUtilities2.setLeadAnchorWithoutSelection( getSelectionModel(), lead, anchor); } } else { if (dropLocation == null) { int[] inds = getSelectedIndices(); retVal = new int[][] {inds, {getAnchorSelectionIndex(), getLeadSelectionIndex()}}; } else { retVal = state; } int index = listLocation.getIndex(); if (index == -1) { clearSelection(); getSelectionModel().setAnchorSelectionIndex(-1); getSelectionModel().setLeadSelectionIndex(-1); } else { setSelectionInterval(index, index); } } } DropLocation old = dropLocation; dropLocation = listLocation; firePropertyChange("dropLocation", old, dropLocation); return retVal; }
Example 20
Source File: JList.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** * Called to set or clear the drop location during a DnD operation. * In some cases, the component may need to use it's internal selection * temporarily to indicate the drop location. To help facilitate this, * this method returns and accepts as a parameter a state object. * This state object can be used to store, and later restore, the selection * state. Whatever this method returns will be passed back to it in * future calls, as the state parameter. If it wants the DnD system to * continue storing the same state, it must pass it back every time. * Here's how this is used: * <p> * Let's say that on the first call to this method the component decides * to save some state (because it is about to use the selection to show * a drop index). It can return a state object to the caller encapsulating * any saved selection state. On a second call, let's say the drop location * is being changed to something else. The component doesn't need to * restore anything yet, so it simply passes back the same state object * to have the DnD system continue storing it. Finally, let's say this * method is messaged with <code>null</code>. This means DnD * is finished with this component for now, meaning it should restore * state. At this point, it can use the state parameter to restore * said state, and of course return <code>null</code> since there's * no longer anything to store. * * @param location the drop location (as calculated by * <code>dropLocationForPoint</code>) or <code>null</code> * if there's no longer a valid drop location * @param state the state object saved earlier for this component, * or <code>null</code> * @param forDrop whether or not the method is being called because an * actual drop occurred * @return any saved state for this component, or <code>null</code> if none */ Object setDropLocation(TransferHandler.DropLocation location, Object state, boolean forDrop) { Object retVal = null; DropLocation listLocation = (DropLocation)location; if (dropMode == DropMode.USE_SELECTION) { if (listLocation == null) { if (!forDrop && state != null) { setSelectedIndices(((int[][])state)[0]); int anchor = ((int[][])state)[1][0]; int lead = ((int[][])state)[1][1]; SwingUtilities2.setLeadAnchorWithoutSelection( getSelectionModel(), lead, anchor); } } else { if (dropLocation == null) { int[] inds = getSelectedIndices(); retVal = new int[][] {inds, {getAnchorSelectionIndex(), getLeadSelectionIndex()}}; } else { retVal = state; } int index = listLocation.getIndex(); if (index == -1) { clearSelection(); getSelectionModel().setAnchorSelectionIndex(-1); getSelectionModel().setLeadSelectionIndex(-1); } else { setSelectionInterval(index, index); } } } DropLocation old = dropLocation; dropLocation = listLocation; firePropertyChange("dropLocation", old, dropLocation); return retVal; }