Java Code Examples for javax.swing.JComboBox.getPreferredSize()

The following are Jave code examples for showing how to use getPreferredSize() of the javax.swing.JComboBox class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Equella   File: ClientLauncher.java   Source Code and License Vote up 5 votes
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;
}
 
Example 2
Project: Equella   File: ItemStatusAccessControlTab.java   Source Code and License Vote up 5 votes
@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));
}
 
Example 3
Project: Equella   File: WhereModel.java   Source Code and License Vote up 5 votes
@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;
}
 
Example 4
Project: Equella   File: TransformDialog.java   Source Code and License Vote up 5 votes
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));
}
 
Example 5
Project: Equella   File: JCalendar.java   Source Code and License Vote up 5 votes
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;
}
 
Example 6
Project: Equella   File: ItemChoicePage.java   Source Code and License Vote up 4 votes
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();
}
 
Example 7
Project: Equella   File: ImportPage.java   Source Code and License Vote up 4 votes
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));
}
 
Example 8
Project: Equella   File: ModeratorsTab.java   Source Code and License Vote up 4 votes
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();
}
 
Example 9
Project: Equella   File: SpecialUsersFinder.java   Source Code and License Vote up 4 votes
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));
}