本文整理汇总了Java中javax.swing.JLabel.setFont方法的典型用法代码示例。如果您正苦于以下问题:Java JLabel.setFont方法的具体用法?Java JLabel.setFont怎么用?Java JLabel.setFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JLabel
的用法示例。
在下文中一共展示了JLabel.setFont方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TextPanel
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* Create the panel.
*/
public TextPanel(String text) {
JLabel lblUpdateChangelog = new JLabel("Update description/change-log:");
JScrollPane scrollPane = new JScrollPane();
JLabel lblDoYouWant = new JLabel("Do you want to install this update?");
lblDoYouWant.setFont(new Font("Tahoma", Font.PLAIN, 15));
lblDoYouWant.setHorizontalAlignment(SwingConstants.CENTER);
GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.TRAILING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
.addComponent(lblUpdateChangelog, GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
.addComponent(lblDoYouWant, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE))
.addContainerGap())
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(lblUpdateChangelog)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(lblDoYouWant)
.addContainerGap())
);
JTextArea textArea = new JTextArea();
scrollPane.setViewportView(textArea);
setLayout(groupLayout);
textArea.setEditable(false);
textArea.setText(text);
}
示例2: openNothing
import javax.swing.JLabel; //导入方法依赖的package包/类
public void openNothing()
{
// eanble scrolling
editorScroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
editorScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JLabel label = new JLabel();
label.setText("");
label.setFont(new Font("Monospaced", Font.BOLD, 20));
label.setHorizontalAlignment(JLabel.CENTER);
label.setVerticalAlignment(JLabel.CENTER);
label.setBackground(BloxsColors.$BACKGROUND);
label.setOpaque(true);
editorScroller.getViewport().add(label);
editorScroller.getViewport().validate();
editorScroller.repaint();
}
示例3: createTitle
import javax.swing.JLabel; //导入方法依赖的package包/类
private JComponent createTitle(String text)
{
JLabel lbl = new JLabel(text);
lbl.setFont(new Font("serif", Font.BOLD, 16));
lbl.setBorder(new UnderlineBorder(0, 0, 0, 0));
return lbl;
}
示例4: getCellRenderer
import javax.swing.JLabel; //导入方法依赖的package包/类
public ListCellRenderer getCellRenderer() {
return new DefaultListCellRenderer() {
public Component getListCellRendererComponent(
JList list,
Object value, // value to display
int index, // cell index
boolean isSelected, // is the cell selected
boolean cellHasFocus) // the list and the cell have the focus
{
JLabel label = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
String s = value.toString();
label.setText(s);
//Note currentNote = CurrentProject.getNoteList().getActiveNote();
Note currentNote = CurrentNote.get();
if (currentNote != null) {
if (getNote(index).getId().equals(currentNote.getId()))
label.setFont(label.getFont().deriveFont(Font.BOLD));
}
if (getNote(index).isMarked())
label.setIcon(bookmarkIcon);
//setIcon();
/*if (isSelected) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
}
else {
setBackground(list.getBackground());
setForeground(list.getForeground());
}
setEnabled(list.isEnabled());
setFont(list.getFont());
setOpaque(true);*/
label.setToolTipText(s);
return label;
}
};
}
示例5: inizializza_salaAttesa
import javax.swing.JLabel; //导入方法依赖的package包/类
private void inizializza_salaAttesa() {
imgSalaAttesa = new JLabel(caricaImmagine("dominio/immagini/salaAttesa.jpg"));
fraseSalaAttesa = new JLabel("In attesa di altri giocatori");
Font font = new Font("Sala Attesa", Font.BOLD, 40);
fraseSalaAttesa.setFont(font);
fraseSalaAttesa.setForeground(Color.black);
int strWidth = fraseSalaAttesa.getFontMetrics(font).stringWidth("In attesa di altri giocatori");
imgSalaAttesa.setBounds(this.getWidth() / 2 - 350, 100, 700, 557);
fraseSalaAttesa.setBounds(this.getWidth() / 2 - strWidth / 2, 10, strWidth, 100);
}
示例6: getJPanelEmpty
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* Returns an empty JPanel with an specified test on it.
*
* @param text the text to display
* @return the JPanel
*/
private JPanel getJPanelEmpty(String text) {
JLabel jLabelText = new JLabel(text);
jLabelText.setFont(new Font("Dialog", Font.BOLD, 12));
jLabelText.setHorizontalAlignment(SwingConstants.CENTER);
JPanel emptyPanel = new JPanel();
emptyPanel.setLayout(new BorderLayout());
emptyPanel.add(jLabelText, BorderLayout.CENTER);
return emptyPanel;
}
示例7: UniversalControlSettingPanel
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* Uses a MigLayout("wrap 2, insets 10 15 20 5", "[][fill, grow]")
*/
protected UniversalControlSettingPanel()
{
super(new MigLayout("wrap 2, insets 10 15 20 5", "[][fill, grow]"));
JLabel label = new JLabel(CurrentLocale.get(getTitleKey()));
Font titleFont = label.getFont();
label.setFont(new Font(titleFont.getName(), Font.BOLD, titleFont.getSize()));
add(label, "span 2, gapbottom 10");
}
示例8: estrazioneMazziere
import javax.swing.JLabel; //导入方法依赖的package包/类
private void estrazioneMazziere() {
int nGiocatori = model.getGiocatori().size();
for(int i = 0; i < nGiocatori; i++)
stampaNomeFiches(model.getGiocatori().get(i));
pausa(pausa_breve);
for(int i = 0; i < nGiocatori; i++) {
stampaValoreMano(model.getGiocatori().get(i));
if(i != nGiocatori - 1)
stampaCarta((this.getWidth()*(2*i+1))/((nGiocatori-1)*2) - 125, 180, model.getGiocatori().get(i).getCartaCoperta().toString());
else
stampaCarta(this.getWidth()/2 - 125, 3*this.getHeight()/4 - 60, model.getGiocatori().get(i).getCartaCoperta().toString());
pausa(pausa_breve);
}
pausa(pausa_breve);
Giocatore mazziere = model.getMazziere();
Font font = new Font("Player", Font.BOLD, 70);
JLabel messaggioMazziere = new JLabel("Il mazziere è: " + mazziere.getNome());
messaggioMazziere.setFont(font);
messaggioMazziere.setForeground(Color.black);
int strWidth = messaggioMazziere.getFontMetrics(font).stringWidth("Il mazziere è: " + mazziere.getNome() + " !!");
messaggioMazziere.setBounds(this.getWidth()/2 - strWidth/2, this.getHeight()/2 - 60, strWidth, 90);
sfondo.add(messaggioMazziere);
sfondo.repaint();
pausa(pausa_lunga);
sfondo.removeAll();
needToMarkMazziere = true;
for(int i = 0; i < nGiocatori; i++)
stampaNomeFiches(model.getGiocatori().get(i));
sfondo.repaint();
}
示例9: formatLabel
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* Sets the desired look of the lavel.
*
* @param label
* Label to apply style to.
* @param selected
* If label is selected or not.
*/
default void formatLabel(JLabel label, boolean selected) {
label.setFont(Fonts.monospace);
label.setOpaque(true);
label.setBorder(BorderFactory.createEtchedBorder());
if (selected) {
label.setBackground(Color.decode(getTheme().listItemSelected));
} else {
label.setBackground(Color.decode(getTheme().listItemBackground));
}
}
示例10: TestWizardPanel
import javax.swing.JLabel; //导入方法依赖的package包/类
public TestWizardPanel() {
counter++;
name = "Panel " + counter;
JLabel jl = new JLabel("<html><center>This is <b>" + name + "</b>.<br>Have a nice day!</center></html>");
jl.setHorizontalAlignment(SwingConstants.CENTER);
jl.setHorizontalTextPosition(SwingConstants.CENTER);
jl.setFont(new Font("Arial", Font.PLAIN, 16));
jl.setBorder(BorderFactory.createEtchedBorder());
setLayout(new BorderLayout());
add(jl, BorderLayout.CENTER);
}
示例11: SelectionBar
import javax.swing.JLabel; //导入方法依赖的package包/类
public SelectionBar()
{
super();
Messenger.register(MT.TIMER_SERVICE_CONNECTION, this);
Messenger.register(MT.SERIES_CHANGED, this);
Messenger.register(MT.NEW_CHALLENGE, this);
Messenger.register(MT.CHALLENGE_DELETED, this);
setBorder(new BevelBorder(0));
Font f = new Font(Font.DIALOG, Font.BOLD, 14);
seriesLabel = new CurrentSeriesLabel();
seriesLabel.setFont(f.deriveFont(Font.PLAIN));
challengeSelect = createCombo("challengeChange");
eventSelect = createCombo("eventChange");
connectLabel = new JLabel("Not Connected");
connectLabel.setForeground(Color.RED);
connectLabel.setFont(f);
add(createLabel("Series:", f));
add(seriesLabel);
add(Box.createHorizontalStrut(40));
add(createLabel("Event:", f));
add(eventSelect);
add(Box.createHorizontalStrut(40));
add(createLabel("Challenge:", f));
add(challengeSelect);
add(Box.createHorizontalStrut(15));
add(createLabel("Timer:", f));
add(connectLabel);
}
示例12: configRenderer
import javax.swing.JLabel; //导入方法依赖的package包/类
private void configRenderer () {
categoryLabel = new JLabel();
categoryLabel.setFont(categoryLabel.getFont().deriveFont(Font.BOLD));
categoryLabel.setBorder(new EmptyBorder(0, 5, 0, 0));
categoryLabel.setForeground(QuickSearchComboBar.getCategoryTextColor());
resultLabel = HtmlRenderer.createLabel();
((HtmlRenderer.Renderer)resultLabel).setHtml(true);
((HtmlRenderer.Renderer)resultLabel).setRenderStyle(HtmlRenderer.STYLE_CLIP);
resultLabel.setOpaque(true);
resultLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4));
shortcutLabel = new JLabel();
shortcutLabel.setOpaque(true);
shortcutLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 4));
cutLabel = new JLabel("...");
cutLabel.setOpaque(true);
cutLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 4));
itemLinePanel = new JPanel();
itemLinePanel.setBackground(QuickSearchComboBar.getResultBackground());
itemLinePanel.setLayout(new BorderLayout());
itemLinePanel.add(resultLabel, BorderLayout.CENTER);
itemPanel = new JPanel();
itemPanel.setBackground(QuickSearchComboBar.getResultBackground());
itemPanel.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 3));
itemPanel.setLayout(new BorderLayout());
itemPanel.add(itemLinePanel, BorderLayout.CENTER);
dividerLine = new JPanel();
dividerLine.setBackground(QuickSearchComboBar.getPopupBorderColor());
dividerLine.setPreferredSize(new Dimension(dividerLine.getPreferredSize().width, 1));
rendererComponent = new JPanel();
rendererComponent.setLayout(new BorderLayout());
rendererComponent.add(itemPanel, BorderLayout.CENTER);
rendererComponent.add(categoryLabel, BorderLayout.WEST);
}
示例13: stylizeHeadingLabel
import javax.swing.JLabel; //导入方法依赖的package包/类
public void stylizeHeadingLabel(JLabel l){
l.setFont(font_20_bold);
l.setForeground(Color.WHITE);
l.setHorizontalAlignment(SwingConstants.LEFT);
}
示例14: setSideMenu
import javax.swing.JLabel; //导入方法依赖的package包/类
private void setSideMenu() {
gridLayout = new GridLayout(8, 1, 0, 0);
sideMenu.setLayout(gridLayout);
sideMenu.setBackground(Color.BLACK);
playerTurn = new JLabel("Turn");
playerTurn.setFont(new Font("Verdana", 0, 20));
playerTurn.setForeground(new Color(255, 255, 255));
player1Name = new JLabel();
player1Name.setFont(new Font("Verdana", 0, 20));
player1Name.setForeground(new Color(255, 255, 255));
player1Score = new JLabel();
player1Score.setIcon(blue);
player1Score.setFont(new Font("Verdana", 0, 35));
player1Score.setForeground(new Color(255, 255, 255));
player2Name = new JLabel();
player2Name.setFont(new Font("Verdana", 0, 20));
player2Name.setForeground(new Color(255, 255, 255));
player2Score = new JLabel();
player2Score.setIcon(red);
player2Score.setFont(new Font("Verdana", 0, 35));
player2Score.setForeground(new Color(255, 255, 255));
winner = new JLabel("Winner");
winner.setFont(new Font("Verdana", 0, 20));
winner.setForeground(new Color(255, 255, 255));
winner.setVisible(false);
sideMenu.add(playerTurn);
sideMenu.add(player1Name);
sideMenu.add(player1Score);
sideMenu.add(new JLabel());
sideMenu.add(player2Name);
sideMenu.add(player2Score);
sideMenu.add(new JLabel());
sideMenu.add(winner);
}
示例15: getJLabelHeader
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* Gets the JLabel for a header.
* @param headerText the header text
* @return the JLabel header
*/
private JLabel getJLabelHeader(String headerText) {
JLabel jLabelHeader = new JLabel(" " + headerText);
jLabelHeader.setFont(new Font("Dialog", Font.BOLD, 12));
return jLabelHeader;
}