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


Java JComboBox.getPreferredSize方法代码示例

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


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

示例1: createServerList

import javax.swing.JComboBox; //导入方法依赖的package包/类
private JComponent createServerList()
{
	JLabel profileLabel = new JLabel("Choose a Server:");

	configureLink = new JLabel("Configure...");
	configureLink.setForeground(Color.BLUE);
	configureLink.addMouseListener(this);

	profileChoice = new JComboBox();
	profileChoice.addActionListener(this);
	profileChoice.setRenderer(new DefaultListCellRenderer()
	{
		@Override
		public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
			boolean cellHasFocus)
		{
			super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
			ServerProfile p = (ServerProfile) value;
			if( p != null )
			{
				setText(p.getName() + " - " + p.getServer());
			}
			return this;
		}
	});

	final int height1 = profileChoice.getPreferredSize().height;
	final int width1 = configureLink.getPreferredSize().width;

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

	JPanel all = new JPanel(new TableLayout(rows, cols));
	all.add(profileLabel, new Rectangle(0, 0, 1, 1));
	all.add(configureLink, new Rectangle(1, 0, 1, 1));
	all.add(profileChoice, new Rectangle(0, 1, 2, 1));

	return all;
}
 
开发者ID:equella,项目名称:Equella,代码行数:40,代码来源:ClientLauncher.java

示例2: init

import javax.swing.JComboBox; //导入方法依赖的package包/类
@Override
public void init(Component parent)
{
	JLabel text = new JLabel(CurrentLocale.get("security.editor.itemstatus")); //$NON-NLS-1$

	statuses = new JComboBox();

	for( ItemStatus status : ItemStatus.values() )
	{
		statuses.addItem(status);
	}

	statuses.addActionListener(new ActionListener()
	{
		@Override
		public void actionPerformed(ActionEvent e)
		{
			saveCurrentSelection();
			loadCurrentSelection();
		}
	});

	editor = new AccessEditor(clientService.getService(RemoteTLEAclManager.class),
		clientService.getService(RemoteUserService.class));

	final int height1 = statuses.getPreferredSize().height;
	final int width1 = text.getPreferredSize().width;

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

	setLayout(new TableLayout(rows, cols));
	add(text, new Rectangle(0, 0, 1, 1));
	add(statuses, new Rectangle(1, 0, 1, 1));
	add(editor, new Rectangle(0, 1, 3, 1));
}
 
开发者ID:equella,项目名称:Equella,代码行数:37,代码来源:ItemStatusAccessControlTab.java

示例3: createCentre

import javax.swing.JComboBox; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected JPanel createCentre()
{
	typeCombo = new JComboBox(TYPES.toArray());
	xpathField = new WhereTargetChooser(new SchemaModel());
	operatorCombo = new JComboBox(OPERATORS.toArray());
	valueSelection = new JComboBox();

	UpdateHandler listener = new UpdateHandler();
	typeCombo.addActionListener(listener);
	xpathField.addTargetListener(new LHSHandler());
	operatorCombo.addActionListener(listener);

	final int height = typeCombo.getPreferredSize().height;
	final int width1 = typeCombo.getPreferredSize().width;
	final int width2 = operatorCombo.getPreferredSize().width;

	final int[] rows = {TableLayout.FILL, height, TableLayout.FILL,};
	final int[] columns = {width1, TableLayout.FILL, width2, TableLayout.FILL,};

	JPanel all = new JPanel(new TableLayout(rows, columns, 0, 5));

	all.add(typeCombo, new Rectangle(0, 1, 1, 1));
	all.add(xpathField, new Rectangle(1, 1, 1, 1));
	all.add(operatorCombo, new Rectangle(2, 1, 1, 1));
	all.add(valueSelection, new Rectangle(3, 1, 1, 1));

	return all;
}
 
开发者ID:equella,项目名称:Equella,代码行数:30,代码来源:WhereModel.java

示例4: setupGui

import javax.swing.JComboBox; //导入方法依赖的package包/类
private void setupGui()
{
	JLabel typeLabel = new JLabel(CurrentLocale.get("com.tle.admin.schema.manager.transformdialog.name")); //$NON-NLS-1$
	JLabel fileLabel = new JLabel(CurrentLocale.get("com.tle.admin.schema.manager.transformdialog.xsl")); //$NON-NLS-1$

	schemaType = new JComboBox();
	schemaType.setEditable(true);
	fileSelector = new FileSelector(CurrentLocale.get("com.tle.admin.schema.manager.transformdialog.browse")); //$NON-NLS-1$
	fileSelector.setFileFilter(FileFilterAdapter.XSLT());

	ok = new JButton(CurrentLocale.get("com.tle.admin.ok")); //$NON-NLS-1$
	JButton cancel = new JButton(CurrentLocale.get("com.tle.admin.cancel")); //$NON-NLS-1$

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

	final int height1 = typeLabel.getPreferredSize().height;
	final int height2 = schemaType.getPreferredSize().height;
	final int height3 = fileSelector.getPreferredSize().height;
	final int height4 = ok.getPreferredSize().height;
	final int width1 = cancel.getPreferredSize().width;

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

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

	all.add(typeLabel, new Rectangle(0, 0, 3, 1));
	all.add(schemaType, new Rectangle(0, 1, 3, 1));
	all.add(fileLabel, new Rectangle(0, 2, 3, 1));
	all.add(fileSelector, new Rectangle(0, 3, 3, 1));
	all.add(ok, new Rectangle(1, 4, 1, 1));
	all.add(cancel, new Rectangle(2, 4, 1, 1));
}
 
开发者ID:equella,项目名称:Equella,代码行数:36,代码来源:TransformDialog.java

示例5: createNorth

import javax.swing.JComboBox; //导入方法依赖的package包/类
private JComponent createNorth()
{
	Map<TextAttribute, Float> fontAttributes = new HashMap<TextAttribute, Float>();
	fontAttributes.put(TextAttribute.SIZE, 30f);
	fontAttributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);

	dateDisplay = new JLabel();
	dateDisplay.setVerticalAlignment(SwingConstants.BOTTOM);
	dateDisplay.setFont(new Font(fontAttributes));
	dateDisplay.setForeground(Color.BLUE);

	months = new JComboBox(MONTHS);
	years = new JComboBox();

	for( int i = YEAR_START; i <= YEAR_END; i++ )
	{
		years.addItem(Integer.valueOf(i));
	}

	months.addActionListener(this);
	years.addActionListener(this);

	final int height1 = months.getPreferredSize().height;
	final int width1 = months.getPreferredSize().width;

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

	JPanel all = new JPanel(new TableLayout(rows, cols, 5, 5));
	all.add(dateDisplay, new Rectangle(0, 0, 1, 2));
	all.add(months, new Rectangle(1, 0, 1, 1));
	all.add(years, new Rectangle(1, 1, 1, 1));

	return all;
}
 
开发者ID:equella,项目名称:Equella,代码行数:36,代码来源:JCalendar.java

示例6: setup

import javax.swing.JComboBox; //导入方法依赖的package包/类
private void setup()
{
	errorLabel = new JLabel();
	errorIcon = Icons.getErrorIcon();

	JLabel heading = new JLabel("<html><h2>Item Selection");
	JLabel help1 = new JLabel("<html><b>Select which items to export:");

	ownerItemButton = new JRadioButton("Items that I own", true);
	allItemsDefButton = new JRadioButton("All items on the server");
	itemDefButton = new JRadioButton("Items of the following type:");
	searchButton = new JRadioButton("Items matching the search query:");

	ButtonGroup exportGroup = new ButtonGroup();
	exportGroup.add(ownerItemButton);
	exportGroup.add(allItemsDefButton);
	exportGroup.add(itemDefButton);
	exportGroup.add(searchButton);

	ownerItemButton.addActionListener(this);
	allItemsDefButton.addActionListener(this);
	itemDefButton.addActionListener(this);
	searchButton.addActionListener(this);

	searchQuery = new JTextField();
	itemDefs = new JComboBox();

	final int height1 = heading.getPreferredSize().height;
	final int height2 = help1.getPreferredSize().height;
	final int height3 = itemDefs.getPreferredSize().height;
	final int width = 10;

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

	setLayout(new TableLayout(rows, cols, 5, 5));
	setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

	add(heading, new Rectangle(0, 0, 3, 1));
	add(help1, new Rectangle(0, 1, 3, 1));

	add(ownerItemButton, new Rectangle(1, 2, 2, 1));
	add(allItemsDefButton, new Rectangle(1, 3, 2, 1));
	add(itemDefButton, new Rectangle(1, 4, 2, 1));
	add(itemDefs, new Rectangle(2, 5, 1, 1));
	add(searchButton, new Rectangle(1, 6, 2, 1));
	add(searchQuery, new Rectangle(2, 7, 1, 1));

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

示例7: setup

import javax.swing.JComboBox; //导入方法依赖的package包/类
private void setup()
{
	JLabel heading = new JLabel("<html><h2>Item Selection");
	JLabel typeLabel = new JLabel("Type");
	JLabel dirLabel = new JLabel("Source");
	JLabel xsltLabel = new JLabel("XSLT");
	JLabel requiredLabel = new JLabel("<html><b>Required:");
	JLabel optionalLabel = new JLabel("<html><b>Optional:");

	xsltTextField = new JTextField();
	dirTextField = new JTextField();

	xsltButton = new JButton("...");
	dirButton = new JButton("...");

	xsltTextField.setEditable(false);
	dirTextField.setEditable(true);

	xsltButton.addActionListener(this);
	dirButton.addActionListener(this);

	typeComboBox = new JComboBox();
	typeComboBox.setEnabled(false);

	dirChooser = new JFileChooser();
	dirChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

	xsltChooser = new JFileChooser();
	xsltChooser.setFileFilter(new XSLTFileFilter());

	final int height1 = typeComboBox.getPreferredSize().height;
	final int height2 = xsltTextField.getPreferredSize().height;
	final int height3 = optionalLabel.getPreferredSize().height;
	final int height4 = heading.getPreferredSize().height;

	final int width2 = xsltButton.getPreferredSize().width;
	final int width3 = dirLabel.getPreferredSize().width + 5;

	final int[] rows = new int[]{height4, height3, height1, height2, height3, height2};
	final int[] cols = new int[]{width3, TableLayout.FILL, width2};

	setLayout(new TableLayout(rows, cols, 5, 0));
	setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

	add(heading, new Rectangle(0, 0, 2, 1));

	add(requiredLabel, new Rectangle(0, 1, 3, 1));

	add(typeLabel, new Rectangle(0, 2, 1, 1));
	add(typeComboBox, new Rectangle(1, 2, 2, 1));

	add(dirLabel, new Rectangle(0, 3, 1, 1));
	add(dirTextField, new Rectangle(1, 3, 1, 1));
	add(dirButton, new Rectangle(2, 3, 1, 1));

	add(optionalLabel, new Rectangle(0, 4, 3, 1));

	add(xsltLabel, new Rectangle(0, 5, 1, 1));
	add(xsltTextField, new Rectangle(1, 5, 1, 1));
	add(xsltButton, new Rectangle(2, 5, 1, 1));
}
 
开发者ID:equella,项目名称:Equella,代码行数:62,代码来源:ImportPage.java

示例8: setupGui

import javax.swing.JComboBox; //导入方法依赖的package包/类
private void setupGui(RemoteUserService userService)
{

	unanimous = new JCheckBox(CurrentLocale.get("com.tle.admin.workflow.editor.moderatorstab.all")); //$NON-NLS-1$
	unanimous.addActionListener(this);

	allowEditing = new JCheckBox(CurrentLocale.get("com.tle.admin.workflow.editor.moderatorstab.allow")); //$NON-NLS-1$

	final int height1 = allowEditing.getPreferredSize().height;

	group = new ButtonGroup();

	finderControl = new MultipleFinderControl(userService);
	finderControl.addActionListener(this);

	staticGroup = GroupBox.withRadioButton(getString("modtab.choosestatic"), false); //$NON-NLS-1$
	staticGroup.getInnerPanel().setLayout(new GridLayout(1, 1));
	staticGroup.add(finderControl);
	staticGroup.addToGroup(group);

	dynamicUserPath = new SingleTargetChooser(schemaModel, null);

	schemaList = new JComboBox();
	schemaList.addItemListener(this);
	for( final NameValue schema : BundleCache.getNameUuidValues(schemaService.listAll()) )
	{
		schemaList.addItem(schema);
	}

	final JLabel dynamicUserPathLabel = new JLabel(
		CurrentLocale.get("com.tle.admin.workflow.editor.autoassigntab.label.target")); //$NON-NLS-1$

	final JLabel schemaLabel = new JLabel(
		CurrentLocale.get("com.tle.admin.workflow.editor.autoassigntab.label.schema")); //$NON-NLS-1$

	final int pathHeight = schemaList.getPreferredSize().height;
	final int pathLabelWidth = schemaLabel.getPreferredSize().width;
	final int[] pathRows = new int[]{pathHeight, pathHeight};
	final int[] pathCols = new int[]{pathLabelWidth, TableLayout.FILL};
	pathGroup = GroupBox.withRadioButton(getString("modtab.choosepath"), false); //$NON-NLS-1$
	pathGroup.getInnerPanel().setLayout(new TableLayout(pathRows, pathCols, 5, 5));
	pathGroup.add(schemaLabel, new Rectangle(0, 0, 1, 1));
	pathGroup.add(schemaList, new Rectangle(1, 0, 1, 1));
	pathGroup.add(dynamicUserPathLabel, new Rectangle(0, 1, 1, 1));
	pathGroup.add(dynamicUserPath, new Rectangle(1, 1, 1, 1));
	pathGroup.addToGroup(group);

	int pathGroupHeight = pathGroup.getPreferredSize().height;
	final int[] rows = {TableLayout.FILL, pathGroupHeight, height1, height1,};
	final int[] cols = {TableLayout.FILL,};

	setLayout(new TableLayout(rows, cols));
	setBorder(AppletGuiUtils.DEFAULT_BORDER);

	add(staticGroup, new Rectangle(0, 0, 1, 1));
	add(pathGroup, new Rectangle(0, 1, 1, 1));
	add(unanimous, new Rectangle(0, 2, 1, 1));
	add(allowEditing, new Rectangle(0, 3, 1, 1));

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

示例9: setupGUI

import javax.swing.JComboBox; //导入方法依赖的package包/类
private void setupGUI(boolean hasOwner)
{
	everyone = new JRadioButton(CurrentLocale.get("com.tle.admin.recipients.specialusersfinder.everyone"), true);
	owner = new JRadioButton(CurrentLocale.get("com.tle.admin.recipients.specialusersfinder.owner"));
	loggedIn = new JRadioButton(CurrentLocale.get("com.tle.admin.recipients.specialusersfinder.loggedin"));
	guest = new JRadioButton(CurrentLocale.get("com.tle.admin.recipients.specialusersfinder.guest"));
	sharedSecretId = new JRadioButton(CurrentLocale.get("com.tle.admin.recipients.specialusersfinder.tokenId"));

	sharedSecretIds = new JComboBox();
	sharedSecretIds.setEnabled(false);
	sharedSecretId.addActionListener(new ActionListener()
	{
		@Override
		public void actionPerformed(ActionEvent e)
		{
			boolean enable = sharedSecretId.isSelected();
			boolean empty = sharedSecretIds.getItemCount() == 0;

			if( enable && empty )
			{
				GlassSwingWorker<List<String>> worker = new GlassSwingWorker<List<String>>()
				{
					@Override
					public List<String> construct() throws Exception
					{
						return userService.getTokenSecretIds();
					}

					@Override
					public void finished()
					{
						AppletGuiUtils.addItemsToJCombo(sharedSecretIds, get());
						sharedSecretIds.setEnabled(true);
					}
				};
				worker.setComponent(SpecialUsersFinder.this);
				worker.start();
			}
			else
			{
				sharedSecretIds.setEnabled(enable);
			}
		}
	});

	ButtonGroup group = new ButtonGroup();
	group.add(everyone);
	group.add(owner);
	group.add(loggedIn);
	group.add(guest);
	group.add(sharedSecretId);

	final int height1 = sharedSecretIds.getPreferredSize().height;

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

	setLayout(new TableLayout(rows, cols));
	int row = -1;
	add(everyone, new Rectangle(0, ++row, 2, 1));
	if( hasOwner )
	{
		add(owner, new Rectangle(0, ++row, 2, 1));
	}
	add(loggedIn, new Rectangle(0, ++row, 2, 1));
	add(guest, new Rectangle(0, ++row, 2, 1));

	add(sharedSecretId, new Rectangle(0, ++row, 2, 1));
	add(sharedSecretIds, new Rectangle(1, ++row, 1, 1));
}
 
开发者ID:equella,项目名称:Equella,代码行数:71,代码来源:SpecialUsersFinder.java


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