Java Code Examples for javax.swing.event.ListDataEvent#getIndex1()
The following examples show how to use
javax.swing.event.ListDataEvent#getIndex1() .
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: PathsCustomizer.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void intervalAdded(ListDataEvent e) { for (int i = e.getIndex1(); i >= e.getIndex0(); i--) { Object obj = listModel.getElementAt(i); if (obj instanceof ClassPathSupport.Item) { DefaultMutableTreeNode node = toTreeNode(obj); treeModel.insertNodeInto(node, (MutableTreeNode)treeModel.getRoot(), e.getIndex0()); TreePath path = new TreePath(node.getPath()); tree.setSelectionPath(path); tree.makeVisible(path); } } }
Example 2
Source File: PathsCustomizer.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void intervalAdded(ListDataEvent e) { for (int i = e.getIndex1(); i >= e.getIndex0(); i--) { Object obj = listModel.getElementAt(i); if (obj instanceof ClassPathSupport.Item) { DefaultMutableTreeNode node = toTreeNode(obj); treeModel.insertNodeInto(node, (MutableTreeNode)treeModel.getRoot(), e.getIndex0()); TreePath path = new TreePath(node.getPath()); tree.setSelectionPath(path); tree.makeVisible(path); } } }
Example 3
Source File: DefaultTabbedContainerUI.java From netbeans with Apache License 2.0 | 5 votes |
public void intervalAdded(ListDataEvent e) { if (container.getContentPolicy() == TabbedContainer.CONTENT_POLICY_ADD_ALL) { Component curC = null; for (int i = e.getIndex0(); i <= e.getIndex1(); i++) { curC = toComp(container.getModel().getTab(i)); contentDisplayer.add(curC, ""); } } }
Example 4
Source File: DefaultTabSelectionModel.java From netbeans with Apache License 2.0 | 5 votes |
private void adjustSelectionForEvent(ListDataEvent e) { if (e.getType() == e.CONTENTS_CHANGED || sel == -1) { return; } int start = e.getIndex0(); int end = e.getIndex1() + 1; if (e.getType() == e.INTERVAL_REMOVED) { if (sel < start) { return; } else { if (sel >= start) { if (sel > end) { sel -= end - start; } else { sel = start; if (sel >= dataModel.size()) { sel = dataModel.size() - 1; } } cs.fireChange(); } } } else { if (sel < start) { //not affected, do nothing return; } if (sel >= start) { if (end - 1 == start) { sel++; } else if (sel < end) { sel = (end + (sel - start)) - 1; } else { sel += (end - start) - 1; } cs.fireChange(); } } }
Example 5
Source File: JMultiSelectionList.java From jeveassets with GNU General Public License v2.0 | 5 votes |
@Override public void intervalAdded(final ListDataEvent e) { int index0 = e.getIndex0(); int index1 = e.getIndex1(); if (index0 == index1) { updateList(index0, 1); } }
Example 6
Source File: JMultiSelectionList.java From jeveassets with GNU General Public License v2.0 | 5 votes |
@Override public void intervalRemoved(final ListDataEvent e) { int index0 = e.getIndex0(); int index1 = e.getIndex1(); if (index0 == index1) { selectedList.remove((Integer) index0); updateList(index0, -1); } else { selectedList.clear(); } ensureIndexIsVisible(index1); }
Example 7
Source File: SkillInfoTab.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void listDataChanged(ListDataEvent e) { if (e.getIndex0() == -1 && e.getIndex1() == -1) { SkillFilter filter = (SkillFilter) skillFilterBox.getSelectedItem(); character.setSkillFilter(filter); skillSheetHandler.support.refresh(); } }
Example 8
Source File: SkillInfoTab.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void listDataChanged(ListDataEvent e) { if (e.getIndex0() == -1 && e.getIndex1() == -1) { SkillFilter filter = (SkillFilter) skillFilterBox.getSelectedItem(); character.setSkillFilter(filter); skillSheetHandler.support.refresh(); } }
Example 9
Source File: PathsCustomizer.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void intervalRemoved(ListDataEvent e) { for (int i = e.getIndex1(); i >= e.getIndex0(); i--) { treeModel.removeNodeFromParent((MutableTreeNode)treeModel.getChild(treeModel.getRoot(), i)); } }
Example 10
Source File: PathsCustomizer.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void intervalRemoved(ListDataEvent e) { for (int i = e.getIndex1(); i >= e.getIndex0(); i--) { treeModel.removeNodeFromParent((MutableTreeNode)treeModel.getChild(treeModel.getRoot(), i)); } }
Example 11
Source File: SearchAutoCompleteSupport.java From cuba with Apache License 2.0 | 4 votes |
public void contentsChanged(ListDataEvent e) { final int newItemCount = comboBox.getItemCount(); // if the size of the model didn't change, the popup size won't change if (previousItemCount != newItemCount) { final int maxPopupItemCount = comboBox.getMaximumRowCount(); // if the popup is showing, check if it must be resized if (popupMenu.isShowing()) { if (comboBox.isShowing()) { // if either the previous or new item count is less than the max, // hide and show the popup to recalculate its new height if (newItemCount < maxPopupItemCount || previousItemCount < maxPopupItemCount) { // don't bother unfiltering the popup since we'll redisplay the popup immediately doNotClearFilterOnPopupHide = true; try { comboBox.hidePopup(); } finally { doNotClearFilterOnPopupHide = false; } comboBox.showPopup(); } } else { // if the comboBox is not showing, simply hide the popup to avoid: // "java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location" // this case can occur when the comboBox is used as a TableCellEditor // and is uninstalled (removed from the component hierarchy) before // receiving this callback comboBox.hidePopup(); } } previousItemCount = newItemCount; } // if the comboBoxModel was changed and it wasn't due to the filter changing // (i.e. !isFiltering) and it wasn't because the user selected a new // selectedItem (i.e. !userSelectedNewItem) then those changes may have // invalidated the invariant that strict mode places on the text in the // JTextField, so we must either: // // a) locate the text within the model (proving that the strict mode invariant still holds) // b) set the text to that of the first element in the model (to reestablish the invariant) final boolean userSelectedNewItem = e.getIndex0() == -1 || e.getIndex1() == -1; if (isStrict() && !userSelectedNewItem && !isFiltering) { // notice that instead of doing the work directly, we post a Runnable here // to check the strict mode invariant and repair it if it is broken. That's // important. It's necessary because we must let the current ListEvent // finish its dispatching before we attempt to change the filter of the // filteredItems list by setting new text into the comboBoxEditorComponent SwingUtilities.invokeLater(checkStrictModeInvariantRunnable); } }
Example 12
Source File: BuddyListModelTest.java From stendhal with GNU General Public License v2.0 | 4 votes |
@Override public void contentsChanged(ListDataEvent e) { contentsChangedFlag = true; index0 = e.getIndex0(); index1 = e.getIndex1(); }
Example 13
Source File: BuddyListModelTest.java From stendhal with GNU General Public License v2.0 | 4 votes |
@Override public void intervalAdded(ListDataEvent e) { intervalAddedFlag = true; index0 = e.getIndex0(); index1 = e.getIndex1(); }
Example 14
Source File: BuddyListModelTest.java From stendhal with GNU General Public License v2.0 | 4 votes |
@Override public void intervalRemoved(ListDataEvent e) { intervalRemovedFlag = true; index0 = e.getIndex0(); index1 = e.getIndex1(); }