当前位置: 首页>>代码示例>>Java>>正文


Java JList.setSelectionMode方法代码示例

本文整理汇总了Java中javax.swing.JList.setSelectionMode方法的典型用法代码示例。如果您正苦于以下问题:Java JList.setSelectionMode方法的具体用法?Java JList.setSelectionMode怎么用?Java JList.setSelectionMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JList的用法示例。


在下文中一共展示了JList.setSelectionMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildListFromComponents

import javax.swing.JList; //导入方法依赖的package包/类
/**
 * Builds a list from the components array.
 * @param components the components array
 * @return a list to be placed on the GUI
 */
JList buildListFromComponents (Component [] components) {
	JList list = new JList();
	
	if (components != null) {
		list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		list.setSize(100,200);
		
		listData = new Vector();
		menuItems = new Hashtable();
		
		// build a hash look-up table and fill list with components's text
		for (int i=0 ; i<components.length ; i++) {
			if (components[i] instanceof JMenuItem) {
				listData.addElement(((JMenuItem)components[i]).getText());
				menuItems.put(((JMenuItem)components[i]).getText(),components[i]);
			}
			else {
				listData.addElement(SEPARATOR_STRING);
				menuItems.put(SEPARATOR_STRING,components[i]);
			}
		}
		
		list.setListData(listData);
	}
		
	return list;
}
 
开发者ID:guilhebl,项目名称:routerapp,代码行数:33,代码来源:MenuManagementWindow.java

示例2: makeList

import javax.swing.JList; //导入方法依赖的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

示例3: initComponents

import javax.swing.JList; //导入方法依赖的package包/类
private void initComponents() {
	setLayout(new BorderLayout(5, 5));
	this.setBorder(new EmptyBorder(20, 20, 20, 20));
	//classesList = new JList(new StationsListModel());
	stationsList = new JList();
	stationsList.setListData(stationData.getStationKeys());
	stationsList.setCellRenderer(new StationElementRenderer());
	stationsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	panelDescription = new JLabel(STATIONS_PAR_DESCRIPTION);
	JScrollPane jsp = new JScrollPane(stationsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
			ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	jsp.setPreferredSize(new Dimension(140, 200));
	add(panelDescription, BorderLayout.NORTH);
	add(jsp, BorderLayout.WEST);
	stationsList.addListSelectionListener(new ListSelectionListener() {
		public void valueChanged(ListSelectionEvent e) {
			updateParsPane();
		}
	});
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:21,代码来源:AllStationsParametersPanel.java

示例4: PluginDialog

import javax.swing.JList; //导入方法依赖的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,代码来源:SearchTool.java

示例5: initComponents

import javax.swing.JList; //导入方法依赖的package包/类
protected void initComponents() {
    services = RunCentralisedMAS.getRunner().getRuntimeServices();
    getContentPane().setLayout(new BorderLayout());

    // Fields
    Vector<String> agNames = new Vector<String>(services.getAgentsNames());
    Collections.sort(agNames);
    lAgs = new JList(agNames);
    lAgs.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    JPanel p = new JPanel(new BorderLayout());
    p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Current agents", TitledBorder.LEFT, TitledBorder.TOP));
    p.add(lAgs, BorderLayout.CENTER);

    getContentPane().add(p, BorderLayout.CENTER);
    getContentPane().add(createButtonsPanel(), BorderLayout.SOUTH);
    ok.setText("Kill");
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:18,代码来源:KillAgentGUI.java

示例6: createLeft

import javax.swing.JList; //导入方法依赖的package包/类
private Component createLeft() {
	usedUnits = new JList(usedUnitsModel);
	usedUnits.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	usedUnits.setVisibleRowCount(rowCount);
	usedUnits.addListSelectionListener(new UsedSelector());
	leftListPane = new JScrollPane(usedUnits);
	return leftListPane;
}
 
开发者ID:etomica,项目名称:etomica,代码行数:9,代码来源:UnitGraphics.java

示例7: FlagsEditorPanel

import javax.swing.JList; //导入方法依赖的package包/类
/** Creates a new instance of FlagsEditorPanel */
public FlagsEditorPanel(String flagString) {
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

    listModel = new FlagListModel(flagString);
    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.addListSelectionListener(this);
    add(new JScrollPane(list));

    add(Box.createHorizontalStrut(3));

    Box buttonBox = new Box(BoxLayout.Y_AXIS);
    buttonBox.add(colorButton = new ColorChooserButton());
    buttonBox.add(newButton = new JButton("New..."));
    buttonBox.add(removeButton = new JButton("Remove"));
    buttonBox.add(upButton = new JButton("Up"));
    buttonBox.add(downButton = new JButton("Down"));
    buttonBox.add(Box.createVerticalGlue());
    add(buttonBox);
    layoutButtonContainer(buttonBox);

    colorButton.setColorChooserEnabled(false);
    colorButton.addActionListener(this);
    newButton.addActionListener(this);
    removeButton.addActionListener(this);
    upButton.addActionListener(this);
    downButton.addActionListener(this);

    selectionChanged(-1); // no selection
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:32,代码来源:FlagsEditorPanel.java

示例8: createNewConfigurableJList

import javax.swing.JList; //导入方法依赖的package包/类
/**
 * Creates a new JList for a given source of a configurable
 *
 * @param source
 *            can be null for local configurables, otherwise name of the source
 * @return the created JList
 */
private JList<Configurable> createNewConfigurableJList(String source) {

	final JList<Configurable> createdConfigList = new JList<>();
	createdConfigList.setModel(source == null ? localConfigListModel : remoteConfigListModels.get(source));
	createdConfigList.setCellRenderer(new ConfigurableRenderer());
	createdConfigList.setFixedCellHeight(40);
	createdConfigList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	createdConfigList.setBackground(LIGHTER_GRAY);

	return createdConfigList;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:19,代码来源:ConfigurableDialog.java

示例9: initComponents

import javax.swing.JList; //导入方法依赖的package包/类
private void initComponents() {
	setLayout(new BorderLayout(5, 5));
	this.setBorder(new EmptyBorder(20, 20, 20, 20));
	//classesList = new JList(new StationsListModel());
	stationsList = new JList();
	stationsList.setListData(stationData.getStationKeys());
	stationsList.setCellRenderer(new StationElementRenderer());
	stationsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	panelDescription = new JLabel(STATIONS_PAR_DESCRIPTION);
	JScrollPane jsp = new JScrollPane(stationsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
			ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	jsp.setPreferredSize(new Dimension(140, 200));
	add(panelDescription, BorderLayout.NORTH);
	add(jsp, BorderLayout.WEST);
	stationsList.addListSelectionListener(new ListSelectionListener() {
		public void valueChanged(ListSelectionEvent e) {
			if (e.getValueIsAdjusting()) {
				return;
			}
			updateParsPane();
		}
	});
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:24,代码来源:AllStationsParametersPanel.java

示例10: createList

import javax.swing.JList; //导入方法依赖的package包/类
private JPanel createList() {
    DefaultListModel listModel = new DefaultListModel();

    for (int i = 0; i < 10; i++) {
        listModel.addElement("List Item " + i);
    }

    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    JScrollPane scrollPane = new JScrollPane(list);
    scrollPane.setPreferredSize(new Dimension(400, 100));

    list.setDragEnabled(true);
    list.setTransferHandler(new ListTransferHandler());

    dropCombo = new JComboBox(new String[] { "USE_SELECTION", "ON", "INSERT", "ON_OR_INSERT" });
    dropCombo.addActionListener(this);
    JPanel dropPanel = new JPanel();
    dropPanel.add(new JLabel("List Drop Mode:"));
    dropPanel.add(dropCombo);

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.add(dropPanel, BorderLayout.SOUTH);
    panel.setBorder(BorderFactory.createTitledBorder("List"));
    return panel;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:28,代码来源:DropDemo.java

示例11: LHSListPane

import javax.swing.JList; //导入方法依赖的package包/类
public LHSListPane(Container paneParent, JList lst)
{
    lst.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    setViewportView(lst);

    int nWidth = (int) ((double) paneParent.getWidth() * PERCENTAGE_WIDTH);
    setSize(nWidth, paneParent.getHeight());
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:9,代码来源:LHSListPane.java

示例12: createRight

import javax.swing.JList; //导入方法依赖的package包/类
private Component createRight() {
	for (int i = 0; i < allUnitStrings.length; i++) {
		selectedUnitsSet.addElement(allUnitStrings[i]);
	}
	allUnits = new JList(selectedUnitsSet);

	allUnits.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	allUnits.setVisibleRowCount(rowCount);
	allUnits.addListSelectionListener(new AllSelector());
	rightListPane = new JScrollPane(allUnits);
	return rightListPane;
}
 
开发者ID:etomica,项目名称:etomica,代码行数:13,代码来源:UnitGraphics.java

示例13: getEntryArea

import javax.swing.JList; //导入方法依赖的package包/类
/** Lazily creates and returns the panel. */
private JList<SelectableListEntry> getEntryArea() {
    if (this.entryArea == null) {
        JList<SelectableListEntry> result = this.entryArea = new JList<>();
        result.setBackground(getColors().getBackground(Mode.NONE));
        result.setForeground(getColors().getForeground(Mode.NONE));
        result.setSelectionBackground(getColors().getBackground(Mode.FOCUSED));
        result.setSelectionForeground(getColors().getBackground(Mode.FOCUSED));
        result.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        result.setCellRenderer(new CellRenderer());
    }
    return this.entryArea;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:14,代码来源:ListPanel.java

示例14: initGUI

import javax.swing.JList; //导入方法依赖的package包/类
/**
 * Initializes GUI.
 */
private void initGUI() {
    PrimListModel model = new PrimListModel();
    JList<Integer> firstList = new JList<Integer>(model);
    JList<Integer> secondList = new JList<Integer>(model);
    JButton next = new JButton("Next");

    firstList
            .setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    firstList.setLayoutOrientation(JList.VERTICAL);
    JScrollPane firstScroller = new JScrollPane(firstList);

    secondList
            .setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    secondList.setLayoutOrientation(JList.VERTICAL);
    JScrollPane secondSroller = new JScrollPane(secondList);

    next.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            model.next();
            revalidate();
        }
    });

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
    panel.add(firstScroller);
    panel.add(secondSroller);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(panel, BorderLayout.CENTER);
    getContentPane().add(next, BorderLayout.PAGE_END);
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:38,代码来源:PrimDemo.java

示例15: setup

import javax.swing.JList; //导入方法依赖的package包/类
private void setup()
{
	JLabel label = new JLabel(CurrentLocale.get("com.tle.admin.workflow.stepdialog.title"));

	model = new GenericListModel<Class<? extends WorkflowNode>>();
	list = new JList(model);
	list.setCellRenderer(new WorkflowCellRenderer());
	list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	list.addListSelectionListener(this);
	list.addMouseListener(this);

	ok = new JButton(CurrentLocale.get("com.tle.admin.ok"));
	cancel = new JButton(CurrentLocale.get("com.tle.admin.cancel"));

	ok.addActionListener(this);
	cancel.addActionListener(this);

	final int height1 = label.getPreferredSize().height;
	final int height2 = ok.getPreferredSize().height;
	final int width1 = cancel.getPreferredSize().width;

	final int[] rows = {height1, TableLayout.FILL, height2,};
	final int[] cols = {TableLayout.FILL, width1, width1,};

	content = new JPanel(new TableLayout(rows, cols));
	content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

	content.add(label, new Rectangle(0, 0, 3, 1));
	content.add(new JScrollPane(list), new Rectangle(0, 1, 3, 1));
	content.add(ok, new Rectangle(1, 2, 1, 1));
	content.add(cancel, new Rectangle(2, 2, 1, 1));

	updateButtons();
}
 
开发者ID:equella,项目名称:Equella,代码行数:35,代码来源:StepDialog.java


注:本文中的javax.swing.JList.setSelectionMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。