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


Java JList.setSize方法代碼示例

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


在下文中一共展示了JList.setSize方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: jButton14ActionPerformed

import javax.swing.JList; //導入方法依賴的package包/類
private void jButton14ActionPerformed(
    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed
    Vector v = new Vector();

    JList l = new JList(v);
    qPanel1.add(l);
    l.setSize(100, 100);

    l.setVisible(true);
    v.add("asdasdads");
    v.add("123123123");
    v.remove(0);
}
 
開發者ID:bcgov,項目名稱:sbc-qsystem,代碼行數:14,代碼來源:FTest.java

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