Java Code Examples for sun.swing.SwingUtilities2#loc2IndexFileList()
The following examples show how to use
sun.swing.SwingUtilities2#loc2IndexFileList() .
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: BasicFileChooserUI.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public void mouseClicked(MouseEvent evt) { // Note: we can't depend on evt.getSource() because of backward // compatibility if (list != null && SwingUtilities.isLeftMouseButton(evt) && (evt.getClickCount()%2 == 0)) { int index = SwingUtilities2.loc2IndexFileList(list, evt.getPoint()); if (index >= 0) { File f = (File)list.getModel().getElementAt(index); try { // Strip trailing ".." f = ShellFolder.getNormalizedFile(f); } catch (IOException ex) { // That's ok, we'll use f as is } if(getFileChooser().isTraversable(f)) { list.clearSelection(); changeDirectory(f); } else { getFileChooser().approveSelection(); } } } }
Example 2
Source File: BasicFileChooserUI.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void mouseClicked(MouseEvent evt) { // Note: we can't depend on evt.getSource() because of backward // compatibility if (list != null && SwingUtilities.isLeftMouseButton(evt) && (evt.getClickCount()%2 == 0)) { int index = SwingUtilities2.loc2IndexFileList(list, evt.getPoint()); if (index >= 0) { File f = (File)list.getModel().getElementAt(index); try { // Strip trailing ".." f = ShellFolder.getNormalizedFile(f); } catch (IOException ex) { // That's ok, we'll use f as is } if(getFileChooser().isTraversable(f)) { list.clearSelection(); changeDirectory(f); } else { getFileChooser().approveSelection(); } } } }
Example 3
Source File: BasicFileChooserUI.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public void mouseClicked(MouseEvent evt) { // Note: we can't depend on evt.getSource() because of backward // compatibility if (list != null && SwingUtilities.isLeftMouseButton(evt) && (evt.getClickCount()%2 == 0)) { int index = SwingUtilities2.loc2IndexFileList(list, evt.getPoint()); if (index >= 0) { File f = (File)list.getModel().getElementAt(index); try { // Strip trailing ".." f = ShellFolder.getNormalizedFile(f); } catch (IOException ex) { // That's ok, we'll use f as is } if(getFileChooser().isTraversable(f)) { list.clearSelection(); changeDirectory(f); } else { getFileChooser().approveSelection(); } } } }
Example 4
Source File: BasicFileChooserUI.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public void mouseClicked(MouseEvent evt) { // Note: we can't depend on evt.getSource() because of backward // compatibility if (list != null && SwingUtilities.isLeftMouseButton(evt) && (evt.getClickCount()%2 == 0)) { int index = SwingUtilities2.loc2IndexFileList(list, evt.getPoint()); if (index >= 0) { File f = (File)list.getModel().getElementAt(index); try { // Strip trailing ".." f = ShellFolder.getNormalizedFile(f); } catch (IOException ex) { // That's ok, we'll use f as is } if(getFileChooser().isTraversable(f)) { list.clearSelection(); changeDirectory(f); } else { getFileChooser().approveSelection(); } } } }
Example 5
Source File: BasicListUI.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public void dragStarting(MouseEvent me) { if (BasicGraphicsUtils.isMenuShortcutKeyDown(me)) { int row = SwingUtilities2.loc2IndexFileList(list, me.getPoint()); list.addSelectionInterval(row, row); } }
Example 6
Source File: BasicListUI.java From JDKSourceCode1.8 with MIT License | 4 votes |
public void mousePressed(MouseEvent e) { if (SwingUtilities2.shouldIgnore(e, list)) { return; } boolean dragEnabled = list.getDragEnabled(); boolean grabFocus = true; // different behavior if drag is enabled if (dragEnabled) { int row = SwingUtilities2.loc2IndexFileList(list, e.getPoint()); // if we have a valid row and this is a drag initiating event if (row != -1 && DragRecognitionSupport.mousePressed(e)) { dragPressDidSelection = false; if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) { // do nothing for control - will be handled on release // or when drag starts return; } else if (!e.isShiftDown() && list.isSelectedIndex(row)) { // clicking on something that's already selected // and need to make it the lead now list.addSelectionInterval(row, row); return; } // could be a drag initiating event - don't grab focus grabFocus = false; dragPressDidSelection = true; } } else { // When drag is enabled mouse drags won't change the selection // in the list, so we only set the isAdjusting flag when it's // not enabled list.setValueIsAdjusting(true); } if (grabFocus) { SwingUtilities2.adjustFocus(list); } adjustSelection(e); }
Example 7
Source File: BasicListUI.java From hottub with GNU General Public License v2.0 | 4 votes |
public void dragStarting(MouseEvent me) { if (BasicGraphicsUtils.isMenuShortcutKeyDown(me)) { int row = SwingUtilities2.loc2IndexFileList(list, me.getPoint()); list.addSelectionInterval(row, row); } }
Example 8
Source File: BasicListUI.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private void adjustSelection(MouseEvent e) { int row = SwingUtilities2.loc2IndexFileList(list, e.getPoint()); if (row < 0) { // If shift is down in multi-select, we should do nothing. // For single select or non-shift-click, clear the selection if (isFileList && e.getID() == MouseEvent.MOUSE_PRESSED && (!e.isShiftDown() || list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION)) { list.clearSelection(); } } else { int anchorIndex = adjustIndex(list.getAnchorSelectionIndex(), list); boolean anchorSelected; if (anchorIndex == -1) { anchorIndex = 0; anchorSelected = false; } else { anchorSelected = list.isSelectedIndex(anchorIndex); } if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) { if (e.isShiftDown()) { if (anchorSelected) { list.addSelectionInterval(anchorIndex, row); } else { list.removeSelectionInterval(anchorIndex, row); if (isFileList) { list.addSelectionInterval(row, row); list.getSelectionModel().setAnchorSelectionIndex(anchorIndex); } } } else if (list.isSelectedIndex(row)) { list.removeSelectionInterval(row, row); } else { list.addSelectionInterval(row, row); } } else if (e.isShiftDown()) { list.setSelectionInterval(anchorIndex, row); } else { list.setSelectionInterval(row, row); } } }
Example 9
Source File: BasicListUI.java From Java8CN with Apache License 2.0 | 4 votes |
public void dragStarting(MouseEvent me) { if (BasicGraphicsUtils.isMenuShortcutKeyDown(me)) { int row = SwingUtilities2.loc2IndexFileList(list, me.getPoint()); list.addSelectionInterval(row, row); } }
Example 10
Source File: BasicListUI.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public void dragStarting(MouseEvent me) { if (BasicGraphicsUtils.isMenuShortcutKeyDown(me)) { int row = SwingUtilities2.loc2IndexFileList(list, me.getPoint()); list.addSelectionInterval(row, row); } }
Example 11
Source File: BasicListUI.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public void mousePressed(MouseEvent e) { if (SwingUtilities2.shouldIgnore(e, list)) { return; } boolean dragEnabled = list.getDragEnabled(); boolean grabFocus = true; // different behavior if drag is enabled if (dragEnabled) { int row = SwingUtilities2.loc2IndexFileList(list, e.getPoint()); // if we have a valid row and this is a drag initiating event if (row != -1 && DragRecognitionSupport.mousePressed(e)) { dragPressDidSelection = false; if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) { // do nothing for control - will be handled on release // or when drag starts return; } else if (!e.isShiftDown() && list.isSelectedIndex(row)) { // clicking on something that's already selected // and need to make it the lead now list.addSelectionInterval(row, row); return; } // could be a drag initiating event - don't grab focus grabFocus = false; dragPressDidSelection = true; } } else { // When drag is enabled mouse drags won't change the selection // in the list, so we only set the isAdjusting flag when it's // not enabled list.setValueIsAdjusting(true); } if (grabFocus) { SwingUtilities2.adjustFocus(list); } adjustSelection(e); }
Example 12
Source File: BasicListUI.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public void mousePressed(MouseEvent e) { if (SwingUtilities2.shouldIgnore(e, list)) { return; } boolean dragEnabled = list.getDragEnabled(); boolean grabFocus = true; // different behavior if drag is enabled if (dragEnabled) { int row = SwingUtilities2.loc2IndexFileList(list, e.getPoint()); // if we have a valid row and this is a drag initiating event if (row != -1 && DragRecognitionSupport.mousePressed(e)) { dragPressDidSelection = false; if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) { // do nothing for control - will be handled on release // or when drag starts return; } else if (!e.isShiftDown() && list.isSelectedIndex(row)) { // clicking on something that's already selected // and need to make it the lead now list.addSelectionInterval(row, row); return; } // could be a drag initiating event - don't grab focus grabFocus = false; dragPressDidSelection = true; } } else { // When drag is enabled mouse drags won't change the selection // in the list, so we only set the isAdjusting flag when it's // not enabled list.setValueIsAdjusting(true); } if (grabFocus) { SwingUtilities2.adjustFocus(list); } adjustSelection(e); }
Example 13
Source File: BasicListUI.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public void mousePressed(MouseEvent e) { if (SwingUtilities2.shouldIgnore(e, list)) { return; } boolean dragEnabled = list.getDragEnabled(); boolean grabFocus = true; // different behavior if drag is enabled if (dragEnabled) { int row = SwingUtilities2.loc2IndexFileList(list, e.getPoint()); // if we have a valid row and this is a drag initiating event if (row != -1 && DragRecognitionSupport.mousePressed(e)) { dragPressDidSelection = false; if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) { // do nothing for control - will be handled on release // or when drag starts return; } else if (!e.isShiftDown() && list.isSelectedIndex(row)) { // clicking on something that's already selected // and need to make it the lead now list.addSelectionInterval(row, row); return; } // could be a drag initiating event - don't grab focus grabFocus = false; dragPressDidSelection = true; } } else { // When drag is enabled mouse drags won't change the selection // in the list, so we only set the isAdjusting flag when it's // not enabled list.setValueIsAdjusting(true); } if (grabFocus) { SwingUtilities2.adjustFocus(list); } adjustSelection(e); }
Example 14
Source File: BasicListUI.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public void dragStarting(MouseEvent me) { if (BasicGraphicsUtils.isMenuShortcutKeyDown(me)) { int row = SwingUtilities2.loc2IndexFileList(list, me.getPoint()); list.addSelectionInterval(row, row); } }
Example 15
Source File: BasicListUI.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
public void dragStarting(MouseEvent me) { if (BasicGraphicsUtils.isMenuShortcutKeyDown(me)) { int row = SwingUtilities2.loc2IndexFileList(list, me.getPoint()); list.addSelectionInterval(row, row); } }
Example 16
Source File: BasicListUI.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
private void adjustSelection(MouseEvent e) { int row = SwingUtilities2.loc2IndexFileList(list, e.getPoint()); if (row < 0) { // If shift is down in multi-select, we should do nothing. // For single select or non-shift-click, clear the selection if (isFileList && e.getID() == MouseEvent.MOUSE_PRESSED && (!e.isShiftDown() || list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION)) { list.clearSelection(); } } else { int anchorIndex = adjustIndex(list.getAnchorSelectionIndex(), list); boolean anchorSelected; if (anchorIndex == -1) { anchorIndex = 0; anchorSelected = false; } else { anchorSelected = list.isSelectedIndex(anchorIndex); } if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) { if (e.isShiftDown()) { if (anchorSelected) { list.addSelectionInterval(anchorIndex, row); } else { list.removeSelectionInterval(anchorIndex, row); if (isFileList) { list.addSelectionInterval(row, row); list.getSelectionModel().setAnchorSelectionIndex(anchorIndex); } } } else if (list.isSelectedIndex(row)) { list.removeSelectionInterval(row, row); } else { list.addSelectionInterval(row, row); } } else if (e.isShiftDown()) { list.setSelectionInterval(anchorIndex, row); } else { list.setSelectionInterval(row, row); } } }
Example 17
Source File: BasicListUI.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
public void mousePressed(MouseEvent e) { if (SwingUtilities2.shouldIgnore(e, list)) { return; } boolean dragEnabled = list.getDragEnabled(); boolean grabFocus = true; // different behavior if drag is enabled if (dragEnabled) { int row = SwingUtilities2.loc2IndexFileList(list, e.getPoint()); // if we have a valid row and this is a drag initiating event if (row != -1 && DragRecognitionSupport.mousePressed(e)) { dragPressDidSelection = false; if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) { // do nothing for control - will be handled on release // or when drag starts return; } else if (!e.isShiftDown() && list.isSelectedIndex(row)) { // clicking on something that's already selected // and need to make it the lead now list.addSelectionInterval(row, row); return; } // could be a drag initiating event - don't grab focus grabFocus = false; dragPressDidSelection = true; } } else { // When drag is enabled mouse drags won't change the selection // in the list, so we only set the isAdjusting flag when it's // not enabled list.setValueIsAdjusting(true); } if (grabFocus) { SwingUtilities2.adjustFocus(list); } adjustSelection(e); }
Example 18
Source File: BasicListUI.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public void mousePressed(MouseEvent e) { if (SwingUtilities2.shouldIgnore(e, list)) { return; } boolean dragEnabled = list.getDragEnabled(); boolean grabFocus = true; // different behavior if drag is enabled if (dragEnabled) { int row = SwingUtilities2.loc2IndexFileList(list, e.getPoint()); // if we have a valid row and this is a drag initiating event if (row != -1 && DragRecognitionSupport.mousePressed(e)) { dragPressDidSelection = false; if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) { // do nothing for control - will be handled on release // or when drag starts return; } else if (!e.isShiftDown() && list.isSelectedIndex(row)) { // clicking on something that's already selected // and need to make it the lead now list.addSelectionInterval(row, row); return; } // could be a drag initiating event - don't grab focus grabFocus = false; dragPressDidSelection = true; } } else { // When drag is enabled mouse drags won't change the selection // in the list, so we only set the isAdjusting flag when it's // not enabled list.setValueIsAdjusting(true); } if (grabFocus) { SwingUtilities2.adjustFocus(list); } adjustSelection(e); }
Example 19
Source File: DarkListUIBridge.java From darklaf with MIT License | 4 votes |
public void dragStarting(final MouseEvent me) { if (DarkUIUtil.isMenuShortcutKeyDown(me)) { int row = SwingUtilities2.loc2IndexFileList(list, me.getPoint()); list.addSelectionInterval(row, row); } }
Example 20
Source File: DarkListUIBridge.java From darklaf with MIT License | 4 votes |
/** * Adjust selection. * * @param e the e */ protected void adjustSelection(final MouseEvent e) { int row = SwingUtilities2.loc2IndexFileList(list, e.getPoint()); if (row < 0) { // If shift is down in multi-select, we should do nothing. // For single select or non-shift-click, clear the selection if (isFileList && e.getID() == MouseEvent.MOUSE_PRESSED && (!e.isShiftDown() || list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION)) { list.clearSelection(); } } else { int anchorIndex = adjustIndex(list.getAnchorSelectionIndex(), list); boolean anchorSelected; if (anchorIndex == -1) { anchorIndex = 0; anchorSelected = false; } else { anchorSelected = list.isSelectedIndex(anchorIndex); } if (DarkUIUtil.isMenuShortcutKeyDown(e)) { if (e.isShiftDown()) { if (anchorSelected) { list.addSelectionInterval(anchorIndex, row); } else { list.removeSelectionInterval(anchorIndex, row); if (isFileList) { list.addSelectionInterval(row, row); list.getSelectionModel().setAnchorSelectionIndex(anchorIndex); } } } else if (list.isSelectedIndex(row)) { list.removeSelectionInterval(row, row); } else { list.addSelectionInterval(row, row); } } else if (e.isShiftDown()) { list.setSelectionInterval(anchorIndex, row); } else { list.setSelectionInterval(row, row); } } }