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


Java ListSelectionModel類代碼示例

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


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

示例1: setSelectionInterval

import javax.swing.ListSelectionModel; //導入依賴的package包/類
public void setSelectionInterval(int index0, int index1) {
    clearSelection();
    if (selectionMode == ListSelectionModel.SINGLE_SELECTION) {
        modifySelectionInterval(index0, index1, true);
    } else {
        modifySelectionInterval(index1, index1, true);
    }
    fireValueChanged();
}
 
開發者ID:addertheblack,項目名稱:myster,代碼行數:10,代碼來源:JMCList.java

示例2: JCheckBoxList

import javax.swing.ListSelectionModel; //導入依賴的package包/類
public JCheckBoxList() {
  setCellRenderer(new CellRenderer());
  addMouseListener(new MouseAdapter() {
    @Override
    public void mousePressed(MouseEvent e) {
      int index = locationToIndex(e.getPoint());
      if (index != -1) {
        JCheckBox checkbox = getModel().getElementAt(index);

        if (e.getPoint().x < checkbox.getHorizontalTextPosition()) {

          checkbox.setSelected(!checkbox.isSelected());
        }
        repaint();
      }
    }
  });
  setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
 
開發者ID:gurkenlabs,項目名稱:litiengine,代碼行數:20,代碼來源:JCheckBoxList.java

示例3: QubitTable

import javax.swing.ListSelectionModel; //導入依賴的package包/類
public QubitTable(final int row_height) {
	setFont(new Font("Tahoma", Font.PLAIN, 12));
	setRowHeight(row_height);
	setFocusable(false);
	setRowSelectionAllowed(false);
	setShowGrid(false);
	setIntercellSpacing(new Dimension(0, 0));
	setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
	setTableHeader(null);
	setModel(new DefaultTableModel(new Object[][] {{"|0>"}}, new String[] {""}));
	
	update_col_width();
	
	qubits = "0";
}
 
開發者ID:QwertygidQ,項目名稱:DeutschSim,代碼行數:17,代碼來源:QubitTable.java

示例4: getComponent

import javax.swing.ListSelectionModel; //導入依賴的package包/類
public JComponent getComponent() {
    if (panel == null) {
        final ListView view = new ListView();
        view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        class Panel extends JPanel implements ExplorerManager.Provider, Lookup.Provider {
            // Make sure action context works correctly:
            {
                setLayout(new BorderLayout());
                add(view, BorderLayout.CENTER);
            }
            public ExplorerManager getExplorerManager() {
                return manager;
            }
            @Override
            public boolean requestFocusInWindow() {
                return view.requestFocusInWindow();
            }
            public Lookup getLookup() {
                return lookup;
            }
        }
        panel = new Panel();
    }
    return panel;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:AntNavigatorPanel.java

示例5: buildTablePanel

import javax.swing.ListSelectionModel; //導入依賴的package包/類
private JScrollPane buildTablePanel() {
      table = new JTable(new AddressBookTableModel(),new DefaultTableColumnModel());
      TableColumn nameColumn = new TableColumn(0);
      TableColumn addressColumn = new TableColumn(1);
      table.addColumn(nameColumn);
      table.addColumn(addressColumn);
      table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // one at a time
      table.getSelectionModel().addListSelectionListener(new AddressListSelectionListener());
      table.addMouseListener(new AddressMouseListener());
      
      // TODO: isolate in utility
TableCellRenderer renderer = table.getCellRenderer(0, 0);
Component comp = renderer.getTableCellRendererComponent(table, "123", false, false, 0, 0);
table.setRowHeight(new Double(comp.getPreferredSize().getHeight()).intValue() + 2);
      
      JScrollPane scrollPane = new JScrollPane(table);
      return scrollPane;
  }
 
開發者ID:ZencashOfficial,項目名稱:zencash-swing-wallet-ui,代碼行數:19,代碼來源:AddressBookPanel.java

示例6: storeToXML

import javax.swing.ListSelectionModel; //導入依賴的package包/類
@Override
public Node storeToXML(Document doc) {
    Object value = getValue();
    int selectionMode = -1;
    Object[] values = getEnumerationValues();
    if (values[4].equals(value)) {
        selectionMode = ListSelectionModel.SINGLE_SELECTION;
    } else if (values[7].equals(value)) {
        selectionMode = ListSelectionModel.SINGLE_INTERVAL_SELECTION;
    } else if (values[10].equals(value)) {
        selectionMode = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION;
    }
    org.w3c.dom.Element el = null;
    el = doc.createElement(XML_TABLE_SELECTION_MODEL);
    el.setAttribute(ATTR_SELECTION_MODE, Integer.toString(selectionMode));
    return el;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:JTableSelectionModelEditor.java

示例7: copyAnchorToSelection

import javax.swing.ListSelectionModel; //導入依賴的package包/類
public void copyAnchorToSelection() {
	if ((getSelectedRowCount() == 0) && (getSelectedColumnCount() == 0)) {
		return;
	}
	if (dataModel instanceof ExactTableModel) {
		stopEditing();
		int rowFrom = selectionModel.getMinSelectionIndex();
		int rowTo = selectionModel.getMaxSelectionIndex();
		ListSelectionModel csm = columnModel.getSelectionModel();
		int colFrom = csm.getMinSelectionIndex();
		int colTo = csm.getMaxSelectionIndex();

		int anchorRow = selectionModel.getAnchorSelectionIndex();
		int anchorCol = csm.getAnchorSelectionIndex();

		((ExactTableModel) dataModel).copyCellToArea(anchorRow, anchorCol, rowFrom, rowTo, colFrom, colTo);
		updateRows(rowFrom, rowTo);
		requestFocus();
	}
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:21,代碼來源:ExactTable.java

示例8: makeList

import javax.swing.ListSelectionModel; //導入依賴的package包/類
private JList<String> makeList(final String[][] items, int visibleRows, Container parent) {
	JList<String> list = new JList<>(new AbstractListModel<String>()	{
		/**
		 * 
		 */
		private static final long serialVersionUID = 6510576197401709714L;

		public String getElementAt(int i) {
			return items[i][0];				
		}
		
		public int getSize() {
			return items.length;
		}
	});

	list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	list.setVisibleRowCount(visibleRows);
	parent.add(new JScrollPane(list));
	return list;
}
 
開發者ID:guilhebl,項目名稱:routerapp,代碼行數:22,代碼來源:OpenGraphDialog.java

示例9: run

import javax.swing.ListSelectionModel; //導入依賴的package包/類
public void run() {
    boolean multisel = (list.getSelectionMode() != ListSelectionModel.SINGLE_SELECTION);
    int i = (multisel ? list.getLeadSelectionIndex() : list.getSelectedIndex());

    if (i < 0) {
        return;
    }

    Point p = list.indexToLocation(i);

    if (p == null) {
        return;
    }

    createPopup(p.x, p.y, false);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:ListView.java

示例10: isSelectionModeBroken

import javax.swing.ListSelectionModel; //導入依賴的package包/類
/** 
 * Check if selection of the nodes could break
 * the selection mode set in the ListSelectionModel.
 * @param nodes the nodes for selection
 * @return true if the selection mode is broken
 */
private boolean isSelectionModeBroken(Node[] nodes) {
    
    // if nodes are empty or single then everthing is ok
    // or if discontiguous selection then everthing ok
    if (nodes.length <= 1 || outline.getSelectionModel().getSelectionMode() == 
            ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) {
        return false;
    }

    // if many nodes
    
    // breaks single selection mode
    if (outline.getSelectionModel().getSelectionMode() == 
        ListSelectionModel.SINGLE_SELECTION) {
        return true;
    }
    
    // check the contiguous selection mode

    // check selection's rows
    
    // all is ok
    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:31,代碼來源:OutlineView.java

示例11: CategoryList

import javax.swing.ListSelectionModel; //導入依賴的package包/類
/**
 * Constructor.
 */
CategoryList( Category category, PalettePanel palettePanel ) {
    this.category = category;
    this.palettePanel = palettePanel;
    if( isGTK || isNimbus ) {
        setBackground( new Color( UIManager.getColor("Tree.background").getRGB() ) );//NOI18N
        setOpaque(true);
    } else {
        if( "Aqua".equals(UIManager.getLookAndFeel().getID()) )
            setBackground(UIManager.getColor("NbExplorerView.background"));
        else
            setBackground(UIManager.getColor ("Panel.background"));
    }
    setBorder (new EmptyBorder (0, 0, 0, 0));
    setVisibleRowCount (0);
    setSelectionMode (ListSelectionModel.SINGLE_SELECTION);
    setCellRenderer (getItemRenderer ());
    setLayoutOrientation( HORIZONTAL_WRAP );
    getAccessibleContext().setAccessibleName( category.getDisplayName() );
    getAccessibleContext().setAccessibleDescription( category.getShortDescription() );

    initActions();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:CategoryList.java

示例12: initList

import javax.swing.ListSelectionModel; //導入依賴的package包/類
@NbBundle.Messages({
    "MSG_Detecting_Wait=Detecting installations, please wait..."
})
private void initList() {
    installationList.setListData(new Object[]{
        Bundle.MSG_Detecting_Wait()
    });
    installationList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    installationList.setEnabled(false);

    RequestProcessor.getDefault().post(new Runnable() {
        @Override
        public void run() {
            final List<Installation> installations =
                    InstallationManager.detectAllInstallations();
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    updateListForDetectedInstallations(installations);
                }
            });
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:SelectInstallationPanel.java

示例13: selectRows

import javax.swing.ListSelectionModel; //導入依賴的package包/類
public void selectRows() throws Throwable {
    final JTable table = (JTable) ComponentUtils.findComponent(JTable.class, frame);
    final LoggingRecorder lr = new LoggingRecorder();
    siw(new Runnable() {
        @Override public void run() {
            table.setRowSelectionAllowed(true);
            table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            table.addRowSelectionInterval(1, 1);
            table.addRowSelectionInterval(3, 3);
            table.addColumnSelectionInterval(0, 0);
            RTable rTable = new RTable(table, null, null, lr);
            rTable.focusLost(null);
        }
    });
    Call call = lr.getCall();
    AssertJUnit.assertEquals("select", call.getFunction());
    AssertJUnit.assertEquals("rows:[1,3],columns:[First Name]", call.getState());
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:19,代碼來源:RTableTest.java

示例14: PluginDialog

import javax.swing.ListSelectionModel; //導入依賴的package包/類
public PluginDialog()
{
	listModel = new DefaultListModel();

	list = new JList();
	list.setModel(listModel);
	list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

	for( String name : plugins.keySet() )
	{
		listModel.addElement(name);
	}

	setLayout(new BorderLayout());
	add(new JScrollPane(list));
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:17,代碼來源:HarvesterProfileTool.java

示例15: getComponent

import javax.swing.ListSelectionModel; //導入依賴的package包/類
public JComponent getComponent() {
    if (panel == null) {
        final BeanTreeView view = new BeanTreeView();
        view.setRootVisible(false);
        view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        class Panel extends JPanel implements ExplorerManager.Provider, Lookup.Provider {
            // Make sure action context works correctly:
            private final Lookup lookup = ExplorerUtils.createLookup(manager, new ActionMap());
            {
                setLayout(new BorderLayout());
                add(view, BorderLayout.CENTER);
            }
            public ExplorerManager getExplorerManager() {
                return manager;
            }
            public Lookup getLookup() {
                return lookup;
            }
        }
        panel = new Panel();
    }
    return panel;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:ErrorNavigatorProviderImpl.java


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