本文整理了Java中javax.swing.JLabel.setPreferredSize()
方法的一些代码示例,展示了JLabel.setPreferredSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLabel.setPreferredSize()
方法的具体详情如下:
包路径:javax.swing.JLabel
类名称:JLabel
方法名:setPreferredSize
暂无
代码示例来源:origin: dcevm/dcevm
private JComponent getBanner() {
try {
BufferedImage img = ImageIO.read(getClass().getResource("splash.png"));
JLabel title = new JLabel(new ImageIcon(img));
title.setPreferredSize(new Dimension(img.getWidth() + 10, img.getHeight()));
title.setOpaque(true);
title.setBackground(new Color(238, 238, 255));
return title;
} catch (Exception ignore) {
}
return new JLabel();
}
代码示例来源:origin: runelite/runelite
UICombinedActionSlot(SpriteManager spriteManager)
{
setLayout(new BorderLayout());
setBackground(ColorScheme.DARKER_GRAY_COLOR);
setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));
JLabel uiIcon = new JLabel();
uiIcon.setBorder(new EmptyBorder(0, 0, 0, 5));
spriteManager.addSpriteTo(uiIcon, 582, 0);
uiIcon.setMinimumSize(ICON_SIZE);
uiIcon.setMaximumSize(ICON_SIZE);
uiIcon.setPreferredSize(ICON_SIZE);
uiIcon.setHorizontalAlignment(JLabel.CENTER);
add(uiIcon, BorderLayout.LINE_START);
JPanel uiInfo = new JPanel(new GridLayout(2, 1));
uiInfo.setBackground(ColorScheme.DARKER_GRAY_COLOR);
uiLabelTitle = new JShadowedLabel("No Action Selected");
uiLabelTitle.setForeground(Color.WHITE);
uiLabelActions = new JShadowedLabel("Shift-click to select multiple");
uiLabelActions.setFont(FontManager.getRunescapeSmallFont());
uiLabelActions.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
uiInfo.add(uiLabelTitle);
uiInfo.add(uiLabelActions);
add(uiInfo, BorderLayout.CENTER);
}
代码示例来源:origin: wildfly/wildfly
public void start() throws Exception {
mainFrame=new JFrame("Chat demo");
mainFrame.setPreferredSize(new Dimension(600,600));
mainFrame.setBackground(Color.white);
mainFrame.addWindowListener(new WindowAdapter() {
txtArea.setPreferredSize(new Dimension(550, 500));
txtArea.setEditable(false);
txtArea.setBackground(Color.white);
main_box.add(buttons);
csLabel.setPreferredSize(new Dimension(85, 30));
input.add(csLabel);
代码示例来源:origin: kiegroup/optaplanner
private void createUI() {
JPanel labelAndDeletePanel = new JPanel(new BorderLayout(5, 0));
if (employee != null) {
labelAndDeletePanel.add(new JLabel(nurseRosteringPanel.getEmployeeIcon()), BorderLayout.WEST);
}
JLabel employeeLabel = new JLabel(getEmployeeLabel());
employeeLabel.setEnabled(false);
labelAndDeletePanel.add(employeeLabel, BorderLayout.CENTER);
if (employee != null) {
JPanel deletePanel = new JPanel(new BorderLayout());
deleteButton = SwingUtils.makeSmallButton(new JButton(nurseRosteringPanel.getDeleteEmployeeIcon()));
deleteButton.setToolTipText("Delete");
deleteButton.addActionListener(e -> nurseRosteringPanel.deleteEmployee(employee));
deletePanel.add(deleteButton, BorderLayout.NORTH);
labelAndDeletePanel.add(deletePanel, BorderLayout.EAST);
}
labelAndDeletePanel.setPreferredSize(new Dimension(WEST_HEADER_WIDTH,
(int) labelAndDeletePanel.getPreferredSize().getHeight()));
add(labelAndDeletePanel, BorderLayout.WEST);
resetShiftListPanel();
numberOfShiftAssignmentsLabel = new JLabel("0 assignments", JLabel.RIGHT);
numberOfShiftAssignmentsLabel.setPreferredSize(new Dimension(EAST_HEADER_WIDTH, 20));
numberOfShiftAssignmentsLabel.setEnabled(false);
add(numberOfShiftAssignmentsLabel, BorderLayout.EAST);
}
代码示例来源:origin: magefree/mage
private void setGUISize() {
Font font = GUISizeHelper.gameRequestsFont;
lblText.setFont(font);
lblText.setMaximumSize(new Dimension(300 + font.getSize() * 15, 20 + font.getSize() * 5));
lblText.setMinimumSize(new Dimension(300 + font.getSize() * 15, 20 + font.getSize() * 5));
lblText.setPreferredSize(new Dimension(300 + font.getSize() * 15, 20 + font.getSize() * 5));
btn1.setFont(font);
btn1.setMinimumSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
btn1.setMaximumSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
btn1.setPreferredSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
btn2.setFont(font);
btn2.setMinimumSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
btn2.setMaximumSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
btn2.setPreferredSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
btn3.setFont(font);
btn3.setMinimumSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
btn3.setMaximumSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
btn3.setPreferredSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
JComponent c = ((BasicInternalFrameUI) this.getUI()).getNorthPane();
c.setMinimumSize(new Dimension(c.getMinimumSize().width, font.getSize() + 10));
c.setMaximumSize(new Dimension(c.getMaximumSize().width, font.getSize() + 10));
c.setPreferredSize(new Dimension(c.getPreferredSize().width, font.getSize() + 10));
c.setFont(font);
}
代码示例来源:origin: chewiebug/GCViewer
Panel logoPanel = new Panel();
ImageIcon logoIcon = ImageHelper.loadImageIcon(LocalisationHelper.getString("about_dialog_image"));
JLabel la_icon = new JLabel(logoIcon);
la_icon.setBorder(new SoftBevelBorder(SoftBevelBorder.LOWERED));
logoPanel.add(la_icon);
versionPanel.setLayout(new GridBagLayout());
JLabel copyright = new JLabel("\u00A9" + " 2011-2018: Joerg Wuethrich and contributors", JLabel.CENTER);
JLabel contributorsLabel = new JLabel("contributors (alphabetically ordered):", JLabel.CENTER);
contributorsLabel.setForeground(Color.GRAY);
JLabel contributors = new JLabel(formatContributors(CONTRIBUTORS), JLabel.CENTER);
contributors.setPreferredSize(calculatePreferredSize(contributors, true, logoIcon.getIconWidth()));
JLabel version = new JLabel("<html><font color=\"gray\">version:</font> " + BuildInfoReader.getVersion() + "</html>", JLabel.CENTER);
代码示例来源:origin: kiegroup/optaplanner
private void createUI() {
JPanel labelAndDeletePanel = new JPanel(new BorderLayout());
labelAndDeletePanel.setPreferredSize(new Dimension(150, 20));
machineLabel = new JLabel(getMachineLabel());
machineLabel.setEnabled(false);
labelAndDeletePanel.add(machineLabel, BorderLayout.CENTER);
resetResourceListPanel();
JPanel numberAndDetailsPanel = new JPanel(new BorderLayout());
numberOfProcessesLabel = new JLabel("0 processes ", JLabel.RIGHT);
numberOfProcessesLabel.setPreferredSize(new Dimension(100, 20));
numberOfProcessesLabel.setEnabled(false);
numberAndDetailsPanel.add(numberOfProcessesLabel, BorderLayout.WEST);
代码示例来源:origin: org.netbeans.api/org-openide-dialogs
numberLabel.setFont(ta.getFont());
numberLabel.setOpaque(false);
numberLabel.setPreferredSize(new Dimension(25, 0));
add(numberLabel, BorderLayout.WEST);
taWidth -= 25;
代码示例来源:origin: triplea-game/triplea
@Override
public void addTab(final String tab, final Component contents) {
super.addTab(tab, contents);
final JLabel sizedLabel = new JLabel(tab);
sizedLabel.setPreferredSize(tabDimension);
super.setTabComponentAt(tabIndex, sizedLabel);
tabIndex++;
}
}
代码示例来源:origin: runelite/runelite
itemIcon.setPreferredSize(new Dimension(45, 45));
offerInfo.setFont(FontManager.getRunescapeSmallFont());
JLabel switchFaceViewIcon = new JLabel();
switchFaceViewIcon.setIcon(RIGHT_ARROW_ICON);
switchFaceViewIcon.setVerticalAlignment(JLabel.CENTER);
switchFaceViewIcon.setHorizontalAlignment(JLabel.CENTER);
switchFaceViewIcon.setPreferredSize(new Dimension(30, 45));
offerSpent.setFont(FontManager.getRunescapeSmallFont());
JLabel switchDetailsViewIcon = new JLabel();
switchDetailsViewIcon.setIcon(LEFT_ARROW_ICON);
switchDetailsViewIcon.setVerticalAlignment(JLabel.CENTER);
switchDetailsViewIcon.setHorizontalAlignment(JLabel.CENTER);
switchDetailsViewIcon.setPreferredSize(new Dimension(30, 45));
代码示例来源:origin: nodebox/nodebox
public PortRow(NodeBoxDocument document, String portName, JComponent control) {
this.document = document;
this.portName = portName;
addMouseListener(this);
setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
Dimension labelSize = new Dimension(PortView.LABEL_WIDTH, 16);
Port port = getPort();
label = new ShadowLabel(port.getDisplayLabel());
if (! port.getDescription().isEmpty())
label.setToolTipText(port.getName() + ": " + port.getDescription());
else
label.setToolTipText(port.getName());
label.setBorder(null);
label.setPreferredSize(labelSize);
label.setMinimumSize(labelSize);
this.control = control;
control.setBorder(BorderFactory.createEmptyBorder(TOP_PADDING, 0, BOTTOM_PADDING, 0));
popupMenu = new JPopupMenu();
popupMenu.add(new RevertToDefaultAction());
add(this.label);
add(Box.createHorizontalStrut(10));
add(this.control);
add(Box.createHorizontalGlue());
// Compensate for the popup button.
add(Box.createHorizontalStrut(30));
setBorder(Theme.PARAMETER_ROW_BORDER);
}
代码示例来源:origin: runelite/runelite
private void addItemToPanel(FeedItem item)
avatarAndRight.setPreferredSize(new Dimension(0, 56));
JLabel avatar = new JLabel();
avatar.setPreferredSize(new Dimension(52, 48));
avatar.setBorder(new EmptyBorder(0, 4, 0, 0));
JLabel titleLabel = new JLabel(item.getTitle());
titleLabel.setFont(FontManager.getRunescapeSmallFont());
titleLabel.setBackground(null);
titleLabel.setForeground(darkerForeground);
titleLabel.setPreferredSize(new Dimension(CONTENT_WIDTH - TIME_WIDTH, 0));
JLabel timeLabel = new JLabel(durationToString(duration));
timeLabel.setFont(FontManager.getRunescapeSmallFont());
timeLabel.setForeground(darkerForeground);
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-vmd-game
private void resizeLabels() {
Dimension d = labelTiledLayers.getPreferredSize();
this.labelTiledLayers.setPreferredSize(new Dimension(this.getWidth(), d.getSize().height));
d = labelSprites.getPreferredSize();
this.labelSprites.setPreferredSize(new Dimension(this.getWidth(), d.getSize().height));
d = labelScenes.getPreferredSize();
this.labelScenes.setPreferredSize(new Dimension(this.getWidth(), d.getSize().height));
}
代码示例来源:origin: runelite/runelite
JLabel itemIcon = new JLabel();
itemIcon.setPreferredSize(ICON_SIZE);
if (icon != null)
JLabel itemName = new JLabel();
itemName.setForeground(Color.WHITE);
itemName.setMaximumSize(new Dimension(0, 0)); // to limit the label's size for
itemName.setPreferredSize(new Dimension(0, 0)); // items with longer names
itemName.setText(name);
rightPanel.add(itemName);
JLabel gePriceLabel = new JLabel();
if (gePrice > 0)
代码示例来源:origin: us.ihmc/ihmc-robot-data-visualizer
public HideableMediaFrame(String name, int width, int height)
{
super(name);
label.setPreferredSize(new Dimension(width, height));
getContentPane().add(label);
this.width = width;
this.height = height;
pack();
}
代码示例来源:origin: runelite/runelite
popupMenu.add(pauseSkill);
JLabel skillIcon = new JLabel(new ImageIcon(iconManager.getSkillImage(skill)));
skillIcon.setHorizontalAlignment(SwingConstants.CENTER);
skillIcon.setVerticalAlignment(SwingConstants.CENTER);
skillIcon.setPreferredSize(new Dimension(35, 35));
代码示例来源:origin: nl.cloudfarming.client/util-swing
void setIcon(ImageIcon icon) {
iconLabel.setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
iconLabel.setIcon(icon);
this.repaint();
}
代码示例来源:origin: runelite/runelite
input.setPreferredSize(new Dimension(35, 30));
input.setBorder(new EmptyBorder(5, 5, 5, 5));
((AbstractDocument) input.getDocument()).setDocumentFilter(new DocumentFilter()
JLabel label = new JLabel(labelText);
label.setPreferredSize(new Dimension(45, 0));
label.setForeground(Color.WHITE);
slider.setPreferredSize(new Dimension(ColorUtil.MAX_RGB_VALUE + ColorValueSlider.KNOB_WIDTH, 30));
代码示例来源:origin: robo-code/robocode
private void setPreviewLabelFont(JPanel panel) {
String fontName = (String) getFontNameComboBox().getSelectedItem();
int fontStyleFlags = FontStyle.fromName((String) getFontStyleComboBox().getSelectedItem()).getFontStyleFlags();
int fontSize = Integer.parseInt((String) getFontSizeComboBox().getSelectedItem());
Font font = new Font(fontName, fontStyleFlags, fontSize);
getPreviewLabel().setFont(font);
FontMetrics fontMetrics = panel.getFontMetrics(font);
int width = fontMetrics.stringWidth(getPreviewLabel().getText());
int height = fontMetrics.getHeight();
getPreviewLabel().setPreferredSize(new Dimension(width, height));
}
代码示例来源:origin: runelite/runelite
iconWrapperLabel = new JLabel();
iconWrapperLabel.setPreferredSize(new Dimension(30, 0));
iconWrapperLabel.setVerticalAlignment(JLabel.CENTER);
iconWrapperLabel.setHorizontalAlignment(JLabel.CENTER);
clearButton.setPreferredSize(new Dimension(30, 0));
clearButton.setFont(FontManager.getRunescapeBoldFont());
clearButton.setForeground(ColorScheme.PROGRESS_ERROR_COLOR);
内容来源于网络,如有侵权,请联系作者删除!