javax.swing.JLabel.getFont()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中javax.swing.JLabel.getFont()方法的一些代码示例,展示了JLabel.getFont()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLabel.getFont()方法的具体详情如下:
包路径:javax.swing.JLabel
类名称:JLabel
方法名:getFont

JLabel.getFont介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

JLabel label = new JLabel("Underlined Label");
Font font = label.getFont();
Map attributes = font.getAttributes();
attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
label.setFont(font.deriveFont(attributes));

代码示例来源:origin: libgdx/libgdx

nameLabel = new JLabel(effect.toString());
titlePanel.add(nameLabel);
Font font = nameLabel.getFont();
nameLabel.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));

代码示例来源:origin: chewiebug/GCViewer

public ViewBar(ChartPanelView chartPanelView) {
  this.chartPanelView = chartPanelView;
  setLayout(new GridBagLayout());
  this.title.setOpaque(false);
  this.title.setHorizontalAlignment(SwingConstants.LEFT);
  this.title.setFont(this.title.getFont().deriveFont(this.title.getFont().getSize2D()*0.8f));
  //minimize.set
  GridBagConstraints gridBagConstraints = new GridBagConstraints();
  gridBagConstraints.weightx = 2.0;
  gridBagConstraints.anchor = GridBagConstraints.WEST;
  gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
  add(this.title, gridBagConstraints);
  gridBagConstraints.weightx = 0.0;
  gridBagConstraints.weighty = 1.0;
  gridBagConstraints.gridx = 1;
  gridBagConstraints.fill = GridBagConstraints.VERTICAL;
  add(minimizeButton, gridBagConstraints);
  gridBagConstraints.gridx = 2;
  add(closeButton, gridBagConstraints);
  minimizeButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent event) {
      ViewBar.this.chartPanelView.setMinimized(!ViewBar.this.chartPanelView.isMinimized());
    }
  });
  closeButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent event) {
      ViewBar.this.chartPanelView.close();
    }
  });
}

代码示例来源:origin: org.orbisgis/orbisgis-view

public MessageOverlay() {
  iconInfo = new ImageIcon(MessageOverlay.class.getResource("info.gif"));
  iconInfo.setImageObserver(this);
  iconError = new ImageIcon(MessageOverlay.class.getResource("error.gif"));
  iconError.setImageObserver(this);
  icon = iconInfo;
  messageFont = new JLabel().getFont().deriveFont(Font.BOLD);
}

代码示例来源:origin: bobbylight/RSyntaxTextArea

JLabel label = new JLabel();
FontMetrics fm = label.getFontMetrics(label.getFont());
Object hint = null;

代码示例来源:origin: Nilhcem/FakeSMTP

@Override
public void actionPerformed(ActionEvent e) {
  JLabel label = new JLabel();
  Font font = label.getFont();

代码示例来源:origin: Nilhcem/FakeSMTP

/**
 * Creates the label class (with a bold font).
 */
public NbReceivedLabel() {
  Font boldFont = new Font(nbReceived.getFont().getName(), Font.BOLD, nbReceived.getFont().getSize());
  nbReceived.setFont(boldFont);
}

代码示例来源:origin: magefree/mage

Font labelFont = labelRender.getFont();
String labelText = "{W}"; //labelRender.getText(); // need same font size for all -- use max symbol ever, not current text
int stringWidth = labelRender.getFontMetrics(labelFont).stringWidth(labelText);
labelRender.setFont(new Font(labelFont.getName(), Font.PLAIN + Font.BOLD, fontSizeToUse - 1)); // - for "..." fix in text

代码示例来源:origin: stackoverflow.com

JLabel label = new JLabel("Underlined Label");
Font font = label.getFont();
Map attributes = font.getAttributes();
attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
label.setFont(font.deriveFont(attributes));

代码示例来源:origin: libgdx/libgdx

nameLabel = new JLabel(effect.toString());
titlePanel.add(nameLabel);
Font font = nameLabel.getFont();
nameLabel.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));

代码示例来源:origin: orbisgis/orbisgis

public MessageOverlay(int maxLength) {
  max_length = maxLength;
  iconInfo = new ImageIcon(MessageOverlay.class.getResource("info.gif"));
  iconInfo.setImageObserver(this);
  iconError = new ImageIcon(MessageOverlay.class.getResource("error.gif"));
  iconError.setImageObserver(this);
  icon = iconInfo;
  messageFont = new JLabel().getFont().deriveFont(Font.BOLD);
}
public MessageOverlay() {

代码示例来源:origin: winder/Universal-G-Code-Sender

browseCancelButton.addActionListener(evt -> browseCancelButtonActionPerformed(evt));
Font f = currentFile.getFont();
currentFile.setFont(f.deriveFont(f.getStyle() | Font.BOLD));

代码示例来源:origin: magefree/mage

@Override
  public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    JLabel defaultLabel = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    defaultLabel.setHorizontalAlignment(JLabel.CENTER);
    // colors
    String val = (String) value;
    String[] valsList = val.split("/");
    if (valsList.length == 2 && !valsList[0].equals(valsList[1])) {
      // green draw
      Color defaultBack = defaultLabel.getBackground();
      greenLabel.setText(val);
      greenLabel.setHorizontalAlignment(JLabel.CENTER);
      greenLabel.setFont(defaultLabel.getFont());
      greenLabel.setForeground(Color.black);
      greenLabel.setOpaque(true);
      greenLabel.setBackground(new Color(156, 240, 146));
      greenLabel.setBorder(new LineBorder(defaultBack, 1));
      return greenLabel;
    } else {
      // default draw
      return defaultLabel;
    }
  }
};

代码示例来源:origin: plantuml/plantuml

private JComponent getNorthLabel() {
  final JLabel text = new JLabel("PlantUML (" + Version.versionString() + ")");
  final Font font = text.getFont().deriveFont(Font.BOLD, (float) 20.0);
  text.setFont(font);
  final JPanel ptext = new JPanel();
  ptext.add(text);
  final JLabel icon = new JLabel(new ImageIcon(PSystemVersion.getPlantumlImage()));
  final JPanel result = new JPanel(new BorderLayout());
  result.add(ptext, BorderLayout.CENTER);
  result.add(icon, BorderLayout.EAST);
  return result;
}

代码示例来源:origin: ballerina-platform/ballerina-lang

final Spacer spacer1 = new Spacer();
rootPanel.add(spacer1, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
final JLabel label1 = new JLabel();
Font label1Font = this.$$$getFont$$$(null, Font.BOLD, 20, label1.getFont());
if (label1Font != null) label1.setFont(label1Font);
label1.setText("Miscellaneous Settings");
rootPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));

代码示例来源:origin: stackoverflow.com

JTextArea ta = new JTextArea(text);
 ta.setEditable(false);
 ta.setLineWrap(true);
 ta.setWrapStyleWord(true);
 JLabel lb = new JLabel();
 Font f = lb.getFont();
 ta.setFont(f.deriveFont(f.getSize2D() * 0.9f));
 ta.setBorder(lb.getBorder());
 ta.setBackground(new Color(lb.getBackground().getRGB(), true));
 ta.setForeground(new Color(lb.getForeground().getRGB(), true));
 ta.setOpaque(lb.isOpaque());

代码示例来源:origin: magefree/mage

Font font = lifeLabel.getFont();
  font = font.deriveFont(9f);
  lifeLabel.setFont(font);
  changedFontLife = true;
} else if (changedFontLife) {
  Font font = lifeLabel.getFont();
  font = font.deriveFont(12f);
  lifeLabel.setFont(font);
  changedFontLife = false;
int libraryCards = player.getLibraryCount();
if (libraryCards > 99) {
  Font font = libraryLabel.getFont();
  font = font.deriveFont(9f);
  libraryLabel.setFont(font);
  changedFontLibrary = true;
} else if (changedFontLibrary) {
  Font font = libraryLabel.getFont();
if (graveCards > 99) {
  if (!changedFontGrave) {
    Font font = graveLabel.getFont();
  Font font = lifeLabel.getFont();
if (exileCards > 99) {
  if (!changedFontExile) {
    Font font = exileLabel.getFont();

代码示例来源:origin: org.netbeans.api/org-openide-dialogs

@Override
public Component getListCellRendererComponent(
  JList list, Object value, int index, boolean isSelected, boolean cellHasFocus
) {
  if (index == selected) {
    numberLabel.setFont(doDeriveFont(numberLabel.getFont(), Font.BOLD));
    ta.setFont(doDeriveFont(ta.getFont(), Font.BOLD));
  } else {
    numberLabel.setFont(doDeriveFont(numberLabel.getFont(), Font.PLAIN));
    ta.setFont(doDeriveFont(ta.getFont(), Font.PLAIN));
  }
  if (contentNumbered) {
    numberLabel.setText(Integer.toString(index + 1) + "."); // NOI18N
  }
  // #21322: on JDK1.4 wrapping width is cleared between two rendering runs
  Insets taInsets = ta.getInsets();
  ta.setSize(taWidth, taInsets.top + taInsets.bottom + 1);
  ta.setText((String) value);
  return this;
}

代码示例来源:origin: plantuml/plantuml

private JComponent getNorthLabel() {
  final JLabel text = new JLabel("PlantUML (" + Version.versionString() + ")");
  final Font font = text.getFont().deriveFont(Font.BOLD, (float) 20.0);
  text.setFont(font);
  final JPanel ptext = new JPanel();
  ptext.add(text);
  final JLabel icon = new JLabel(new ImageIcon(PSystemVersion.getPlantumlImage()));
  final JPanel result = new JPanel(new BorderLayout());
  result.add(ptext, BorderLayout.CENTER);
  result.add(icon, BorderLayout.EAST);
  return result;
}

代码示例来源:origin: stackoverflow.com

message = new JLabel();
message.setFont(message.getFont().deriveFont(Font.BOLD, 24));
add(message);

相关文章

微信公众号

最新文章

更多

JLabel类方法