本文整理了Java中javax.swing.JLabel.setFont()
方法的一些代码示例,展示了JLabel.setFont()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLabel.setFont()
方法的具体详情如下:
包路径:javax.swing.JLabel
类名称:JLabel
方法名:setFont
暂无
代码示例来源:origin: gocd/gocd
private JLabel label(String content, Font font) {
JLabel jLabel = new JLabel(content);
jLabel.setHorizontalAlignment(JLabel.CENTER);
if (font != null) {
jLabel.setFont(font);
}
return jLabel;
}
代码示例来源:origin: deathmarine/Luyten
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
boolean isSelected, boolean cellHasFocus) {
JLabel renderer = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index,
isSelected, cellHasFocus);
if (value instanceof String) {
renderer.setText((String) value);
renderer.setFont(new Font((String) value, DEFAULT_FONT.getStyle(), DEFAULT_FONT.getSize() + 2));
} else {
renderer.setText("");
}
return renderer;
}
});
代码示例来源:origin: runelite/runelite
private JPanel buildPingField()
{
JPanel column = new JPanel(new BorderLayout());
column.setBorder(new EmptyBorder(0, 5, 0, 5));
pingField = new JLabel("-");
pingField.setFont(FontManager.getRunescapeSmallFont());
column.add(pingField, BorderLayout.EAST);
return column;
}
代码示例来源:origin: gocd/gocd
titleFont = new Font("Lucida Grande", Font.BOLD, 14);
if (titleFont == null) {
titleFont = new Font("SansSerif", Font.BOLD, 14);
bodyFont = new Font("Lucida Grande", Font.PLAIN, 10);
if (bodyFont == null) {
bodyFont = new Font("SansSerif", Font.PLAIN, 10);
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);
aboutLabel[3] = new JLabel("<html><a href='http://localhost:8153/go'>"
+ "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("");
aboutLabel[5] = new JLabel("Java Version " + System.getProperty("java.version"));
aboutLabel[5].setFont(bodyFont);
aboutLabel[6] = new JLabel("Copyright (C) 2015 ThoughtWorks Inc.");
aboutLabel[6].setFont(bodyFont);
aboutLabel[7] = new JLabel("");
代码示例来源:origin: apache/pdfbox
if (bounds2D.isEmpty())
JLabel label = new JLabel(SimpleFont.NO_GLYPH, SwingConstants.CENTER);
int fontSize = Integer.parseInt(PDFDebugger.configuration.getProperty(
"encodingFontSize", "" + label.getFont().getSize()));
label.setFont(new Font(Font.DIALOG, Font.PLAIN, fontSize));
label.setForeground(Color.GRAY);
return label;
return new JLabel(new ImageIcon(bim), SwingConstants.CENTER);
g.drawImage(glyphImage, 0, 0, null);
g.dispose();
return new JLabel(new ImageIcon(cellImage));
JLabel label = new JLabel(o.toString(), SwingConstants.CENTER);
int fontSize = Integer.parseInt(PDFDebugger.configuration.getProperty(
"encodingFontSize", "" + label.getFont().getSize()));
label.setFont(new Font(Font.DIALOG, Font.PLAIN, fontSize));
if (SimpleFont.NO_GLYPH.equals(o) || ".notdef".equals(o))
label.setForeground(Color.GRAY);
代码示例来源: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: runelite/runelite
private JLabel createSmallLabel(String text)
{
JLabel label = new JLabel(text, SwingConstants.CENTER);
label.setFont(FontManager.getRunescapeSmallFont());
label.setForeground(LAP_DATA_COLOR);
return label;
}
}
代码示例来源:origin: runelite/runelite
private void addVarLog(VarType type, String name, String old, String neew)
{
if (!type.getCheckBox().isSelected())
{
return;
}
int tick = client.getTickCount();
SwingUtilities.invokeLater(() ->
{
if (tick != lastTick)
{
lastTick = tick;
JLabel header = new JLabel("Tick " + tick);
header.setFont(FontManager.getRunescapeSmallFont());
header.setBorder(new CompoundBorder(
BorderFactory.createMatteBorder(0, 0, 1, 0, ColorScheme.LIGHT_GRAY_COLOR),
BorderFactory.createEmptyBorder(3, 6, 0, 0)
));
tracker.add(header);
}
tracker.add(new JLabel(String.format("%s %s changed: %s -> %s", type.getName(), name, old, neew)));
// Cull very old stuff
for (; tracker.getComponentCount() > MAX_LOG_ENTRIES; )
{
tracker.remove(0);
}
tracker.revalidate();
});
}
代码示例来源:origin: winder/Universal-G-Code-Sender
browseCancelButton.addActionListener(evt -> browseCancelButtonActionPerformed(evt));
Font f = currentFile.getFont();
currentFile.setFont(f.deriveFont(f.getStyle() | Font.BOLD));
add(browseCancelButton, "r, wmin button, grow");
connection.setLayout(new MigLayout("fill, wrap 3"));
connection.add(portLabel, "al right");
connection.add(portCombo, "span 3");
connection.add(baudLabel, "al right");
connection.add(baudCombo);
connection.add(refreshButton);
代码示例来源:origin: wildfly/wildfly
listbox.setBounds(new Rectangle(210, 30, 150, 160));
err_msg.setBounds(new Rectangle(10, 200, 350, 30));
err_msg.setFont(new Font("Helvetica",Font.ITALIC,12));
err_msg.setForeground(Color.red);
err_msg.setVisible(false);
get.setBounds(new Rectangle(10, 250, 60, 30));
代码示例来源: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: runelite/runelite
public ProgressBar()
{
setLayout(new BorderLayout());
// The background color should be overridden
setBackground(Color.GREEN.darker());
setForeground(Color.GREEN.brighter());
setPreferredSize(new Dimension(100, 16));
leftLabel.setFont(FontManager.getRunescapeSmallFont());
leftLabel.setForeground(Color.WHITE);
leftLabel.setBorder(new EmptyBorder(2, 5, 0, 0));
rightLabel.setFont(FontManager.getRunescapeSmallFont());
rightLabel.setForeground(Color.WHITE);
rightLabel.setBorder(new EmptyBorder(2, 0, 0, 5));
centerLabel.setFont(FontManager.getRunescapeSmallFont());
centerLabel.setForeground(Color.WHITE);
centerLabel.setHorizontalAlignment(SwingConstants.CENTER);
centerLabel.setBorder(new EmptyBorder(2, 0, 0, 0));
// Adds components to be automatically redrawn when paintComponents is called
add(leftLabel, BorderLayout.WEST);
add(centerLabel, BorderLayout.CENTER);
add(rightLabel, BorderLayout.EAST);
}
代码示例来源: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: marytts/marytts
lStatus = new javax.swing.JLabel();
add(bDetails, gridBagConstraints);
lStatus.setFont(new java.awt.Font("Lucida Grande", 0, 10));
lStatus.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
lStatus.setText((desc.isUpdateAvailable() ? "Update available" : desc.getStatus().toString()));
代码示例来源: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: 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: JetBrains/ideavim
public ModalEntryDialog(@NotNull Editor editor, @NotNull String prompt) {
super((Frame)null, true);
myParent = editor.getContentComponent();
myLabel = new JLabel(prompt);
myEntry = new JTextField();
myLabel.setFont(font);
myEntry.setFont(font);
setBackground(myEntry.getBackground());
myLabel.setForeground(myEntry.getForeground());
myLabel.setBackground(myEntry.getBackground());
代码示例来源:origin: skylot/jadx
private Component makeCell(JNode node, int column) {
if (column == 0) {
JLabel label = new JLabel(node.makeLongString() + " ", node.getIcon(), SwingConstants.LEFT);
label.setFont(font);
label.setOpaque(true);
label.setToolTipText(label.getText());
return label;
}
if (!node.hasDescString()) {
return emptyLabel;
}
RSyntaxTextArea textArea = CodeArea.getDefaultArea(mainWindow);
textArea.setLayout(new GridLayout(1, 1));
textArea.setEditable(false);
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
textArea.setText(" " + node.makeDescString());
textArea.setRows(1);
textArea.setColumns(textArea.getText().length() + 1);
if (highlightText != null) {
SearchContext searchContext = new SearchContext(highlightText);
searchContext.setMatchCase(!highlightTextCaseInsensitive);
searchContext.setMarkAll(true);
SearchEngine.markAll(textArea, searchContext);
}
return textArea;
}
代码示例来源:origin: wiztools/rest-client
@Override
public void valueChanged(ListSelectionEvent evt) {
if(jl_font.getSelectedValue()==null || jl_fontSize.getSelectedValue()==null){
return;
}
String fontName = (String)jl_font.getSelectedValue();
int fontSize = Integer.parseInt((String)jl_fontSize.getSelectedValue());
Font f = new Font(fontName, Font.PLAIN, fontSize);
jl_preview.setFont(f);
}
内容来源于网络,如有侵权,请联系作者删除!