当前位置: 首页>>代码示例>>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;未经允许,请勿转载。