Java Code Examples for javax.swing.JLabel.setMaximumSize()

The following are Jave code examples for showing how to use setMaximumSize() of the javax.swing.JLabel 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: rapidminer   File: IOObjectCacheEntryPanel.java   Source Code and License Vote up 5 votes
/**
 * Creates a new {@link IOObjectCacheEntryPanel}.
 *
 * @param icon
 *            The {@link Icon} associated with the entry's type.
 * @param entryType
 *            Human readable representation of the entry's type (e.g., 'Data Table').
 * @param openAction
 *            The action to be performed when clicking in the entry.
 * @param removeAction
 *            An action triggering the removal of the entry.
 */
public IOObjectCacheEntryPanel(Icon icon, String entryType, Action openAction, Action removeAction) {
	super(ENTRY_LAYOUT);

	this.openAction = openAction;

	// add icon label
	JLabel iconLabel = new JLabel(icon);
	add(iconLabel, ICON_CONSTRAINTS);

	// add object type label
	JLabel typeLabel = new JLabel(entryType);
	typeLabel.setMaximumSize(new Dimension(MAX_TYPE_WIDTH, 24));
	typeLabel.setPreferredSize(typeLabel.getMaximumSize());
	typeLabel.setToolTipText(entryType);
	add(typeLabel, TYPE_CONSTRAINTS);

	// add link button performing the specified action, the label displays the entry's key name
	LinkLocalButton openButton = new LinkLocalButton(openAction);
	openButton.setMargin(new Insets(0, 0, 0, 0));
	add(openButton, KEY_CONSTRAINTS);

	// add removal button
	JButton removeButton = new JButton(removeAction);
	removeButton.setBorderPainted(false);
	removeButton.setOpaque(false);
	removeButton.setMinimumSize(buttonSize);
	removeButton.setPreferredSize(buttonSize);
	removeButton.setContentAreaFilled(false);
	removeButton.setText(null);
	add(removeButton, REMOVE_BUTTON_CONSTRAINTS);

	// register mouse listeners
	addMouseListener(hoverMouseListener);
	iconLabel.addMouseListener(dispatchMouseListener);
	typeLabel.addMouseListener(dispatchMouseListener);
	openButton.addMouseListener(dispatchMouseListener);
	removeButton.addMouseListener(dispatchMouseListener);
}
 
Example 2
Project: rapidminer   File: ConfigurableDialog.java   Source Code and License Vote up 4 votes
/**
 * Initializes the GUI.
 */
private void initGUI() {
	realOuterPanel = new JPanel(new BorderLayout());

	outerLayer = new JLayer<JPanel>(realOuterPanel);
	savingGlassPane = new TransparentGlassPanePanel(WAITING_ICON,
			I18N.getGUILabel("configurable_dialog.saving_configurables"), getBackground(), 0.5f);
	outerLayer.setGlassPane(savingGlassPane);
	savingGlassPane.setVisible(false);

	JPanel pagePanel = new JPanel(new BorderLayout());

	// list of configurables
	JPanel configPanel = createConfigPanel();
	// force size so it does not resize itself depending on entered values
	configPanel.setMinimumSize(CONFIG_LIST_SIZE);
	configPanel.setMaximumSize(CONFIG_LIST_SIZE);
	configPanel.setPreferredSize(CONFIG_LIST_SIZE);
	buttonPanel = createConfigurableButtonPanel();
	// create middle spacer
	JLabel spacer = new JLabel();
	spacer.setMinimumSize(DIMENSION_SPACER_MIDDLE);
	spacer.setMaximumSize(DIMENSION_SPACER_MIDDLE);
	spacer.setPreferredSize(DIMENSION_SPACER_MIDDLE);
	// add both to an outer panel for layout reasons
	JPanel outerConfigPanel = new JPanel(new BorderLayout());
	outerConfigPanel.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, Color.LIGHT_GRAY));
	outerConfigPanel.add(configPanel, BorderLayout.CENTER);
	outerConfigPanel.add(buttonPanel, BorderLayout.SOUTH);
	// another panel for layouting
	JPanel outermostConfigPanel = new JPanel(new BorderLayout());
	outermostConfigPanel.add(outerConfigPanel, BorderLayout.CENTER);
	outermostConfigPanel.add(spacer, BorderLayout.EAST);

	// glass pane showed if the user is not able to edit connections due to an old version of
	// the server
	simpleGlassPane = new TransparentGlassPanePanel(null, null, getBackground(), 0.5f);

	// panel displaying the selected configurable
	JPanel paramPanel = createParameterPanel();

	GridBagConstraints c = new GridBagConstraints();
	c.fill = GridBagConstraints.BOTH;
	c.weightx = 1;
	c.weighty = 0.3;
	c.gridwidth = GridBagConstraints.REMAINDER;

	// add panels to page panel
	pagePanel.add(outermostConfigPanel, BorderLayout.WEST);
	pagePanel.add(paramPanel, BorderLayout.CENTER);

	// add page and button panel to outer panel
	realOuterPanel.add(pagePanel, BorderLayout.CENTER);

	layoutDefault(outerLayer, makeSaveButton(), makeCancel());
	setDefaultSize(ButtonDialog.HUGE);
	setLocationRelativeTo(ApplicationFrame.getApplicationFrame());
	setModal(true);
	setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
	addWindowListener(new WindowAdapter() {

		@Override
		public void windowClosing(WindowEvent e) {
			cancelButton.doClick();
		}
	});

	updateButtonState(true);
}
 
Example 3
Project: xdman   File: YoutubeGrabberDlg.java   Source Code and License Vote up 4 votes
void createP1() {
	Box p11 = Box.createVerticalBox();
	p11.setBackground(Color.white);
	p11.setOpaque(true);
	p1 = new JPanel(new BorderLayout());
	Box b1 = Box.createHorizontalBox();
	b1.setBackground(Color.white);
	b1.setOpaque(true);
	b1.setBorder(new EmptyBorder(25, 15, 10, 15));
	JLabel lbl = new JLabel();
	lbl.setText(StringResource.getString("YT_LBL1"));
	lbl.setOpaque(false);
	JLabel icon = new JLabel(XDMIconMap.getIcon("YT_ICON"));
	icon.setMaximumSize(new Dimension(75, 75));
	b1.add(icon);
	b1.add(Box.createRigidArea(new Dimension(10, 10)));
	b1.add(lbl);
	ytaddr = new JTextField();
	ytaddr.setMaximumSize(new Dimension(ytaddr.getMaximumSize().width,
			ytaddr.getPreferredSize().height));
	p11.add(b1);
	Box b2 = Box.createHorizontalBox();
	b2.add(ytaddr);
	b2.setBackground(Color.white);
	b2.setOpaque(true);
	b2.setBorder(new EmptyBorder(10, 15, 15, 15));
	p11.add(b2);
	p11.add(Box.createVerticalStrut(20));

	p1.add(p11);

	Box b3 = Box.createHorizontalBox();
	get_video = new JButton(StringResource.getString("YT_LBL4"));
	btnDim = get_video.getPreferredSize();
	get_video.setName("YT_LBL4");
	get_video.addActionListener(this);
	cancel = new JButton(StringResource.getString("CANCEL"));
	cancel.setName("CANCEL");
	cancel.addActionListener(this);
	cancel.setPreferredSize(btnDim);
	b3.add(Box.createHorizontalGlue());
	b3.add(get_video);
	b3.add(Box.createRigidArea(new Dimension(10, 10)));
	b3.add(cancel);
	b3.setBorder(new EmptyBorder(10, 15, 10, 15));
	b3.setOpaque(true);
	b3.setBackground(StaticResource.titleColor);

	p1.add(b3, BorderLayout.SOUTH);
}