當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultListSelectionModel.setSelectionInterval方法代碼示例

本文整理匯總了Java中javax.swing.DefaultListSelectionModel.setSelectionInterval方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultListSelectionModel.setSelectionInterval方法的具體用法?Java DefaultListSelectionModel.setSelectionInterval怎麽用?Java DefaultListSelectionModel.setSelectionInterval使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.DefaultListSelectionModel的用法示例。


在下文中一共展示了DefaultListSelectionModel.setSelectionInterval方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testEventsONLeadAnchorAfterClearSelection

import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
/**
     * sanity: understand DefaultListSelectionModel behaviour.
     * 
     * Is it allowed that event.getFirstIndex < 0? This happens in 
     * table.clearLeadAnchor
     *
     */
    public void testEventsONLeadAnchorAfterClearSelection() {
        DefaultListSelectionModel selectionModel = new DefaultListSelectionModel();
        int selected = 5;
        selectionModel.setSelectionInterval(selected, selected);
        assertEquals(selected, selectionModel.getAnchorSelectionIndex());
        assertEquals(selected, selectionModel.getLeadSelectionIndex());
//        selectionModel.setLeadAnchorNotificationEnabled(false);
        ListSelectionReport report = new ListSelectionReport();
        selectionModel.addListSelectionListener(report);
        // following lines are copied from table.clearLeadAnchor()
//        selectionModel.setValueIsAdjusting(true);
        selectionModel.clearSelection();
        assertEquals(1, report.getEventCount());
        assertTrue(report.getLastEvent(false).getFirstIndex() >= 0);
        report.clear();
        selectionModel.setAnchorSelectionIndex(-1);
        assertEquals(1, report.getEventCount());
        assertTrue(report.getLastEvent(false).getFirstIndex() >= 0);
        report.clear();
        
        selectionModel.setLeadSelectionIndex(-1);
        assertEquals(1, report.getEventCount());
        assertTrue(report.getLastEvent(false).getFirstIndex() >= 0);
        report.clear();
    }
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:33,代碼來源:ListSelectionIssues.java

示例2: testEventONLeadAnchorAfterClearSelection

import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
/**
 * sanity: understand DefaultListSelectionModel behaviour.
 * 
 * Is it allowed that event.getFirstIndex < 0? This happens in 
 * table.clearLeadAnchor
 *
 */
public void testEventONLeadAnchorAfterClearSelection() {
    DefaultListSelectionModel selectionModel = new DefaultListSelectionModel();
    int selected = 5;
    selectionModel.setSelectionInterval(selected, selected);
    assertEquals(selected, selectionModel.getAnchorSelectionIndex());
    assertEquals(selected, selectionModel.getLeadSelectionIndex());
    selectionModel.setLeadAnchorNotificationEnabled(false);
    ListSelectionReport report = new ListSelectionReport();
    selectionModel.addListSelectionListener(report);
    // following lines are copied from table.clearLeadAnchor()
    selectionModel.setValueIsAdjusting(true);
    selectionModel.clearSelection();
    selectionModel.setAnchorSelectionIndex(-1);
    selectionModel.setLeadSelectionIndex(-1);
    assertEquals("", 0, report.getEventCount(true));
    selectionModel.setValueIsAdjusting(false);
    ListSelectionEvent event = report.getLastEvent(true);  
    assertEquals(5, event.getFirstIndex());
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:27,代碼來源:ListSelectionIssues.java

示例3: testSelectionEvent

import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
@Test
public void testSelectionEvent() {
    DefaultListSelectionModel list = new DefaultListSelectionModel();
    list.setLeadAnchorNotificationEnabled(false);
    list.setSelectionInterval(0, 0);
    ListSelectionReport report = new ListSelectionReport();
    list.addListSelectionListener(report);
    list.addSelectionInterval(1, 1);
    assertEquals(1, report.getEventCount(true));
    assertEquals(1, report.getLastEvent(true).getLastIndex());
    assertEquals(1, report.getLastEvent(true).getFirstIndex());
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:13,代碼來源:JXListSortRevamp.java

示例4: testInsertBeforeSelectedSM

import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
/**
 * Issue #272-swingx: inserted row is selected.
 * Not a bug: documented behaviour of DefaultListSelectionModel.
 */
public void testInsertBeforeSelectedSM() {
    DefaultListSelectionModel model = new DefaultListSelectionModel();
    model.setSelectionInterval(3, 3);
    model.insertIndexInterval(3, 1, true);
    int max = model.getMaxSelectionIndex();
    int min = model.getMinSelectionIndex();
    assertEquals(max, min);
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:13,代碼來源:JTableIssues.java

示例5: fillContents

import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
private void fillContents(FilePath file)
  {
    TreePath matchedPath = null;
    System.out.println("fill contents ... filename is " + file.filename);
    if (file.path.length > 1)   System.out.println(file.path[0] + " - " + file.path[1]);
    // initialize
    if (      ( file.path.length > 0 )
           && ( !file.filename.equals("") )
           && ( (matchedPath=makeMatchedTreePath(file.path)) != null )         ) {
      try {
          DefaultTreeSelectionModel treeSelectionModel = (DefaultTreeSelectionModel)jTree_sdir.getSelectionModel();
          treeSelectionModel.setSelectionPath(matchedPath);

          // set server tree
          this.selectedServerDirTreeIndex = catchSelectedDirectory();
          refreshServerTable(selectedServerDirTreeIndex);

          // set server table
          DefaultListSelectionModel model = (DefaultListSelectionModel)jTable_sdir.getSelectionModel();
          int tindex = searchSelctedIndex(selectedServerDirTreeIndex, file.filename);
          model.setSelectionInterval(tindex,tindex);
          int selectedIndex = jTable_sdir.getSelectedRow();
          JLabel label = (JLabel) jTable_sdir.getValueAt(selectedIndex,2);
          if (label.getText().equals("file")) {
              String index = sDirList[selectedServerDirTreeIndex].childnodeNames[selectedIndex];
              selectedServerFileIndex = new Integer(index).intValue();
              selectedServerFile = getSelectedServerFile();
              prnSelectedServerFile(selectedServerFileIndex);
          }
      } catch (Exception e) {
          e.printStackTrace();
      }
    } else {
          this.selectedServerDirTreeIndex = 0;
//          this.jTree_sdir.setSelectionPath(this.jTree_sdir.getPathForRow(0));
          refreshServerTable(selectedServerDirTreeIndex);

          this.jButton_preview.setEnabled(false);
          this.jButton_upload.setEnabled(false);
    }// end of if else
    this.selectedClientDirTreeNode = "C:";
    this.jTree_cdir.setSelectionPath(this.jTree_cdir.getPathForRow(2));
    refreshClientTable(selectedClientDirTreeNode);
  }
 
開發者ID:wall72,項目名稱:XM-Miner,代碼行數:45,代碼來源:FileSelectPanel.java


注:本文中的javax.swing.DefaultListSelectionModel.setSelectionInterval方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。