本文整理了Java中javax.swing.JLabel.getPreferredSize()
方法的一些代码示例,展示了JLabel.getPreferredSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLabel.getPreferredSize()
方法的具体详情如下:
包路径:javax.swing.JLabel
类名称:JLabel
方法名:getPreferredSize
暂无
代码示例来源:origin: libgdx/libgdx
nameLabel = new JLabel(effect.toString());
titlePanel.add(nameLabel);
Font font = nameLabel.getFont();
new Dimension(0, Math.max(nameLabel.getPreferredSize().height, deleteButton.getPreferredSize().height)));
add(titlePanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(5, 0, 0, 5), 0, 0));
代码示例来源:origin: libgdx/libgdx
nameLabel = new JLabel(effect.toString());
titlePanel.add(nameLabel);
Font font = nameLabel.getFont();
new Dimension(0, Math.max(nameLabel.getPreferredSize().height, deleteButton.getPreferredSize().height)));
add(titlePanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(5, 0, 0, 5), 0, 0));
代码示例来源:origin: gocd/gocd
aboutLabel[0] = new JLabel("");
aboutLabel[1] = new JLabel("Go Server");
aboutLabel[1].setFont(titleFont);
aboutLabel[2] = new JLabel(
"Server Version " + getClass().getPackage().getImplementationVersion());
aboutLabel[2].setFont(bodyFont);
+ "http://localhost:8153/go</a></html>");
aboutLabel[3].setFont(bodyFont);
aboutLabel[3].setSize(aboutLabel[3].getPreferredSize());
aboutLabel[3].addMouseListener(new LinkMouseListener());
aboutLabel[4] = new JLabel("");
代码示例来源:origin: stanfordnlp/CoreNLP
JLabel historyLabel = new JLabel("Recent matches length: ");
final JTextField historySizeField =
new JTextField(Integer.toString(Preferences.getHistorySize()));
displayOptions.add(historySizeField);
JLabel maxMatchesLabel = new JLabel("Max displayed trees: ");
final JTextField maxMatchesSizeField
= new JTextField(Integer.toString(Preferences.getMaxMatches()));
displayOptions.add(maxMatchesSizeField);
JLabel highlightLabel = new JLabel("Highlight color:");
highlightButton = makeColorButton("Pick a new highlight color: ",
Preferences.getHighlightColor(), prefPanel);
JLabel encodingLabel = new JLabel("Character encoding: ");
setEncoding = new JTextField(Preferences.getEncoding());
setEncoding.setPreferredSize(headfinderName.getPreferredSize());
advOptions.add(headfinderName);
advOptions.add(headfinderPicker);
代码示例来源:origin: RaiMan/SikuliX2
@Override
public void setName(String name) {
if (label == null) {
super.setName(name);
this.label = new JLabel(name);
add(label);
}
label.setFont(new Font("sansserif", Font.BOLD, fontSize));
label.setForeground(colorText);
Dimension s = label.getPreferredSize();
label.setLocation((int) (PADDING_X/2), (int) (PADDING_Y/2));
label.setSize(s);
s.height += PADDING_Y;
s.width += PADDING_X;
setActualSize(s);
}
代码示例来源:origin: RaiMan/SikuliX2
titleBar = new JLabel();
titleBar.setFont(new Font("sansserif", Font.BOLD, 14));
titleBar.setBackground(darkyellow);
titleBar.setOpaque(true);
titleBar.setBorder(BorderFactory.createEmptyBorder(5, 5, 3, 5));
titleBar.setSize(titleBar.getPreferredSize());
titleBar.setVisible(false);
代码示例来源:origin: RaiMan/SikuliX2
symbol = new JLabel("?");
symbol.setFont(f);
Dimension size = symbol.getPreferredSize();
symbol.setSize(size);
symbol.setForeground(Color.white);
代码示例来源:origin: stackoverflow.com
// create a label that will be using the run-time font
JLabel prototypeLabel = new JLabel("Not Applicable")
// get the labels preferred sizes
int preferredWidth = prototypeLabel.getPreferredSize().getWidth();
int preferredHeight = prototypeLabel.getPreferredSize().getHeight();
// set the sizes of the table's row and columns
myTable.setRowHeight(preferredHeight);
for(TableColumn column : myTable.getColumnModel.getColumns()){
column.setPreferredWidth(preferredWidth);
}
代码示例来源:origin: JetBrains/jediterm
public static int getTabsHeight() {
return new JLabel("XXX").getPreferredSize().height + 2 + TAB_VERTICAL_PADDING * 2 + TABS_BORDER * 2;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui
public static int getDefaultRowHeight() {
return new JLabel("X").getPreferredSize().height + 2; //NOI18N
}
代码示例来源:origin: ZencashOfficial/zencash-swing-wallet-ui
private void addFormField(JPanel detailsPanel, String name, JComponent field)
{
JPanel tempPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 2));
JLabel tempLabel = new JLabel(name, JLabel.RIGHT);
// TODO: hard sizing of labels may not scale!
final int width = new JLabel("ZEN amount to send with every message:").getPreferredSize().width + 30;
tempLabel.setPreferredSize(new Dimension(width, tempLabel.getPreferredSize().height));
tempPanel.add(tempLabel);
tempPanel.add(field);
detailsPanel.add(tempPanel);
}
代码示例来源:origin: ZencashOfficial/zencash-swing-wallet-ui
private void addFormField(JPanel detailsPanel, String name, JComponent field)
{
JPanel tempPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 2));
JLabel tempLabel = new JLabel(name, JLabel.RIGHT);
// TODO: hard sizing of labels may not scale!
final int width = new JLabel("Sender identification T address:").getPreferredSize().width + 10;
tempLabel.setPreferredSize(new Dimension(width, tempLabel.getPreferredSize().height));
tempPanel.add(tempLabel);
tempPanel.add(field);
detailsPanel.add(tempPanel);
}
代码示例来源:origin: BTCPrivate/bitcoin-private-full-node-wallet
private void addFormField(JPanel detailsPanel, String name, JComponent field) {
JPanel tempPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 2));
JLabel tempLabel = new JLabel(name, JLabel.RIGHT);
// TODO: hard sizing of labels may not scale!
final int width = new JLabel(LOCAL_MSG_SENDER_ID_B_ADDR).getPreferredSize().width + 10;
tempLabel.setPreferredSize(new Dimension(width, tempLabel.getPreferredSize().height));
tempPanel.add(tempLabel);
tempPanel.add(field);
detailsPanel.add(tempPanel);
}
代码示例来源:origin: BTCPrivate/bitcoin-private-full-node-wallet
private void addFormField(JPanel detailsPanel, String name, JComponent field) {
JPanel tempPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 2));
JLabel tempLabel = new JLabel(name, JLabel.RIGHT);
final int width = new JLabel(LOCAL_MSG_AMOUN_PER_MSG).getPreferredSize().width + 30;
tempLabel.setPreferredSize(new Dimension(width, tempLabel.getPreferredSize().height));
tempPanel.add(tempLabel);
tempPanel.add(field);
detailsPanel.add(tempPanel);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-profiler
private int getColumnWidth() {
int width = new JLabel(Bundle.LBL_LastCalibrated() + "XXX") // NOI18N
.getPreferredSize().width;
width = Math.max(width, new JLabel(Bundle.LBL_NotCalibrated() + "XXX") // NOI18N
.getPreferredSize().width);
width = Math.max(width, new JLabel(DateFormat.getDateInstance()
.format(new Date()) + "XXX").getPreferredSize().width); // NOI18N
width = Math.max(width, new JLabel(DateFormat.getTimeInstance()
.format(new Date()) + "XXX").getPreferredSize().width); // NOI18N
return width;
}
代码示例来源:origin: stackoverflow.com
JLabel label = new JLabel("small");
Dimension d = label.getPreferredSize();
PropertyChangeListener l = new PropertyChangeListener() ...
boolean called;
propertyChanged(...)
called = true;
label.addPropertyChangeListener("preferredSize", l);
label.setText("just some longer text");
if (!d.equals(label.getPreferredSize())
assertTrue("listener must have been notified", l.called);
代码示例来源:origin: com.synaptix/SynaptixSwing
private static JLabel createLabel(String text) {
JLabel label = new JLabel(text);
label.setOpaque(true);
label.setBackground(Color.red);
label.setForeground(Color.white);
label.setSize(label.getPreferredSize());
return label;
}
代码示例来源:origin: stackoverflow.com
JLabel label new JLabel("some text");
label.setBorder(....);
Dimension d = label.getPreferredSize();
d.width = 32767;
label.setMaximumSize( d );
代码示例来源:origin: cytoscape.coreplugins/quickfind
/**
* Creates Search Label.
*/
private JLabel createSearchLabel() {
JLabel label = new JLabel(SEARCH_STRING);
label.setBorder(new EmptyBorder(0, 5, 0, 0));
label.setForeground(Color.GRAY);
// Fix width of label
label.setMaximumSize(label.getPreferredSize());
return label;
}
代码示例来源:origin: stackoverflow.com
JLabel label = new JLabel("Hi");
panel.add(label);
//This is to get the width and height
Dimension size = label.getPreferredSize();
//You can change 100(x) and 100(y) for your likes, so you can put that JLabel wherever you want
label.setBounds(100, 100, size.width, size.height);
内容来源于网络,如有侵权,请联系作者删除!