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


Java JList.setListData方法代碼示例

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


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

示例1: 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

示例2: 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

示例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) {
			if (e.getValueIsAdjusting()) {
				return;
			}
			updateParsPane();
		}
	});
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:24,代碼來源:AllStationsParametersPanel.java

示例4: MenuManagementWindow

import javax.swing.JList; //導入方法依賴的package包/類
/**
 * Creates an instance of this class.
 * @param menu the menu that will be edited by the user
 * @param indexOffset the offset of the editable area
 * @param indexLimit the limit of the editable area
 */
public MenuManagementWindow(JMenu menu,int indexOffset,int indexLimit) {
	this.setBounds(250,200,400,300);
	this.setTitle("Menu management");
	this.setResizable(false);
	this.setModal(true);
	
	this.managedMenu = menu;
	this.emptyMenu   = false;
	this.offset = indexOffset;
	this.limit  = indexLimit;
	
	itemsList = buildListFromComponents(
		trimComponentsByOffsets(menu.getMenuComponents(),offset,limit)
	);
	removedItemsList = new JList();
	removedItemsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	removedItemsList.setListData(removedItems = new Vector());
	removedItemsList.setSize(100,200);
	
	buildButtons();
	
	JPanel okCancelPanel = new JPanel(new FlowLayout());
	okCancelPanel.add(okButton);
	okCancelPanel.add(cancelButton);
	
	JPanel separatorButtonsPanel = new JPanel(new FlowLayout());
	separatorButtonsPanel.setBorder(BorderFactory.createTitledBorder("Separator"));
	separatorButtonsPanel.add(insertSeparatorButton);
	separatorButtonsPanel.add(removeSeparatorButton);

	JPanel itemsPanel = new JPanel();
	itemsPanel.setLayout(new BoxLayout(itemsPanel,BoxLayout.Y_AXIS));
	itemsPanel.setPreferredSize(new Dimension(175,200));
	itemsPanel.add(new JLabel("Menu items:"));
	
	JScrollPane listScroll = new JScrollPane(itemsList);
	itemsPanel.add(listScroll);
	itemsPanel.add(separatorButtonsPanel);
	
	JPanel removedItemsPanel = new JPanel();
	removedItemsPanel.setLayout(new BoxLayout(removedItemsPanel,BoxLayout.Y_AXIS));
	removedItemsPanel.setPreferredSize(new Dimension(175,200));
	removedItemsPanel.add(new JLabel("Removed items:"));
	
	JScrollPane removedListScroll = new JScrollPane(removedItemsList);
	removedItemsPanel.add(removedListScroll);
	
	JPanel itemsButtonsPanel = new JPanel();
	itemsButtonsPanel.setLayout(new BoxLayout(itemsButtonsPanel,BoxLayout.Y_AXIS));
	itemsButtonsPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
	itemsButtonsPanel.add(removeItemButton);
	itemsButtonsPanel.add(retrieveButton);
	
	JPanel centerPanel = new JPanel();
	centerPanel.setLayout(new BoxLayout(centerPanel,BoxLayout.X_AXIS));
	centerPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
	centerPanel.add(itemsPanel);
	centerPanel.add(itemsButtonsPanel);
	centerPanel.add(removedItemsPanel);
	
	JPanel southPanel = new JPanel(new BorderLayout());
	southPanel.add(okCancelPanel,BorderLayout.EAST);
	
	this.getContentPane().setLayout(new BorderLayout());
	this.getContentPane().add(centerPanel,BorderLayout.CENTER);
	this.getContentPane().add(southPanel,BorderLayout.SOUTH);
}
 
開發者ID:guilhebl,項目名稱:routerapp,代碼行數:74,代碼來源:MenuManagementWindow.java


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