本文整理了Java中javax.swing.JLabel.setForeground()
方法的一些代码示例,展示了JLabel.setForeground()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLabel.setForeground()
方法的具体详情如下:
包路径:javax.swing.JLabel
类名称:JLabel
方法名:setForeground
暂无
代码示例来源:origin: runelite/runelite
void updateStatus(String text, Color color)
{
statusLabel.setText(text);
statusLabel.setForeground(color);
}
}
代码示例来源: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 JPanel createInfoPanel(String text)
{
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(new EmptyBorder(7, 8, 6, 8));
panel.setBackground(ColorScheme.DARK_GRAY_COLOR);
JLabel infoLabel = new JShadowedLabel(text);
infoLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR.darker());
infoLabel.setFont(FontManager.getRunescapeSmallFont());
panel.add(infoLabel);
return panel;
}
代码示例来源:origin: jbox2d/jbox2d
if (value.isCategory()) {
if (categoryLabel == null) {
categoryLabel = new JLabel();
categoryLabel.setOpaque(true);
categoryLabel.setBackground(new Color(.5f, .5f, .6f));
categoryLabel.setForeground(Color.white);
categoryLabel.setHorizontalAlignment(SwingConstants.CENTER);
categoryLabel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
categoryLabel.setText(value.category);
return categoryLabel;
} else {
if (testLabel == null) {
testLabel = new JLabel();
testLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 1, 0));
testLabel.setText(value.test.getTestName());
testLabel.setForeground(list.getSelectionForeground());
} else {
testLabel.setBackground(list.getBackground());
testLabel.setForeground(list.getForeground());
代码示例来源:origin: kiegroup/optaplanner
JLabel tooBigToShowLabel = new JLabel("The dataset is too big to show.");
tooBigToShowLabel.setForeground(Color.WHITE);
add(tooBigToShowLabel);
return;
add(button);
} else {
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createLineBorder(TangoColorFactory.ALUMINIUM_6),
代码示例来源:origin: JetBrains/ideavim
private ExEntryPanel() {
setBorder(BorderFactory.createEtchedBorder());
label = new JLabel(" ");
entry = new ExTextField();
entry.setBorder(null);
setFontForElements();
setForeground(entry.getForeground());
setBackground(entry.getBackground());
label.setForeground(entry.getForeground());
label.setBackground(entry.getBackground());
GridBagLayout layout = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
setLayout(layout);
gbc.gridx = 0;
layout.setConstraints(this.label, gbc);
add(this.label);
gbc.gridx = 1;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
layout.setConstraints(entry, gbc);
add(entry);
setBorder(BorderFactory.createEtchedBorder());
adapter = new ComponentAdapter() {
public void componentResized(ComponentEvent e) {
positionPanel();
}
};
}
代码示例来源: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: MovingBlocks/Terasology
MyRenderer() {
setBackground(BACKGROUND);
setLayout(new BorderLayout());
pHead.setLayout(new BorderLayout());
pHead.setBackground(BACKGROUND);
pHead.add(pList, BorderLayout.LINE_START);
pHead.add(lActive, BorderLayout.LINE_END);
pHead.add(pError, BorderLayout.PAGE_END);
lId.setHorizontalAlignment(SwingConstants.RIGHT);
lName.setForeground(Color.BLUE);
lCounters.setForeground(Color.GRAY);
pList.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 2));
pList.setBackground(BACKGROUND);
pList.add(lId);
pList.add(lName);
pList.add(lCounters);
pError.setVisible(false);
pError.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 2));
pError.setBackground(BACKGROUND);
pError.add(lErrorSpacer);
pError.add(lError);
lError.setForeground(Color.RED);
add(pHead, BorderLayout.PAGE_START);
}
代码示例来源:origin: runelite/runelite
public PluginErrorPanel()
{
setOpaque(false);
setBorder(new EmptyBorder(50, 10, 0, 10));
setLayout(new BorderLayout());
noResultsTitle.setForeground(Color.WHITE);
noResultsTitle.setHorizontalAlignment(SwingConstants.CENTER);
noResultsDescription.setFont(FontManager.getRunescapeSmallFont());
noResultsDescription.setForeground(Color.GRAY);
noResultsDescription.setHorizontalAlignment(SwingConstants.CENTER);
add(noResultsTitle, BorderLayout.NORTH);
add(noResultsDescription, BorderLayout.CENTER);
setVisible(false);
}
代码示例来源:origin: libgdx/libgdx
bottomPanel = new JPanel(new GridBagLayout());
contentPane.add(content, new GridBagConstraints(0, 0, 1, 1, 1, 1, NORTH, BOTH, new Insets(0, 0, 0, 0), 0, 0));
JLabel settings = new JLabel("Settings");
JLabel description = new JLabel("Description");
settings.setForeground(new Color(255, 255, 255));
description.setForeground(new Color(255, 255, 255));
mavenTextField.setMinimumSize(mavenTextField.getPreferredSize());
mavenLabel.setForeground(new Color(170, 170, 170));
mavenDesc.setForeground(new Color(170, 170, 170));
ideaBox = new SetupCheckBox();
ideaLabel.setForeground(new Color(170, 170, 170));
ideaDesc.setForeground(new Color(170, 170, 170));
eclipseBox = new SetupCheckBox();
eclipseLabel.setForeground(new Color(170, 170, 170));
eclipseDesc.setForeground(new Color(170, 170, 170));
offlineLabel.setForeground(new Color(170, 170, 170));
offlineDesc.setForeground(new Color(170, 170, 170));
offlineBox.setBackground(new Color(36, 36, 36));
kotlinBox = new SetupCheckBox();
kotlinLabel.setForeground(new Color(170, 170, 170));
kotlinDesc.setForeground(new Color(170, 170, 170));
代码示例来源: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: marytts/marytts
protected void showMessage(String message, boolean warning) {
jLabel_MessageBarIcon.setText(""); // No text, just an icon
if (warning) {
jLabel_MessageBarIcon.setIcon(IconSet.WARNING_16X16);
jLabel_MessageBar.setForeground(Color.RED); // PRI4 Make darker red (more readable than default red)
} else {
jLabel_MessageBarIcon.setIcon(IconSet.INFO_16X16);
jLabel_MessageBar.setForeground(Color.BLACK);
}
jLabel_MessageBar.setText(message); // Display the actual message next to the icon
jLabel_MessageBar.setForeground(Color.BLACK);
}
代码示例来源:origin: stackoverflow.com
label = new JLabel();
label.setOpaque(true);
fileSystemView = FileSystemView.getFileSystemView();
File file = (File)node.getUserObject();
label.setIcon(fileSystemView.getSystemIcon(file));
label.setText(fileSystemView.getSystemDisplayName(file));
label.setToolTipText(file.getPath());
label.setForeground(textSelectionColor);
} else {
label.setBackground(backgroundNonSelectionColor);
label.setForeground(textNonSelectionColor);
代码示例来源:origin: runelite/runelite
JLabel label = new JLabel(labelText);
label.setPreferredSize(new Dimension(45, 0));
label.setForeground(Color.WHITE);
代码示例来源:origin: magefree/mage
labelRender.setText("{" + symbol + "}");
labelRender.setForeground(symbolsTextColor);
labelRender.setSize(symbolWidth, symbolWidth);
labelRender.setVerticalAlignment(SwingConstants.CENTER);
labelRender.setFont(new Font(labelFont.getName(), Font.PLAIN + Font.BOLD, fontSizeToUse - 1)); // - for "..." fix in text
代码示例来源:origin: magefree/mage
public CountryItemEditor() {
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.setBackground(new Color(0, 100,190, 255));
panel.add(labelItem);
labelItem.setAlignmentX(Component.LEFT_ALIGNMENT);
labelItem.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
labelItem.setBorder(new EmptyBorder(0, 5, 0, 0));
labelItem.setOpaque(false);
labelItem.setForeground(Color.WHITE);
editValue = null;
}
代码示例来源: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: runelite/runelite
private JPanel buildCheckboxPanel(SkillDataBonus bonus)
{
JPanel uiOption = new JPanel(new BorderLayout());
JLabel uiLabel = new JLabel(bonus.getName());
JCheckBox uiCheckbox = new JCheckBox();
uiLabel.setForeground(Color.WHITE);
uiLabel.setFont(FontManager.getRunescapeSmallFont());
uiOption.setBorder(BorderFactory.createEmptyBorder(3, 7, 3, 0));
uiOption.setBackground(ColorScheme.DARKER_GRAY_COLOR);
// Adjust XP bonus depending on check-state of the boxes.
uiCheckbox.addActionListener(event -> adjustCheckboxes(uiCheckbox, bonus));
uiCheckbox.setBackground(ColorScheme.MEDIUM_GRAY_COLOR);
uiOption.add(uiLabel, BorderLayout.WEST);
uiOption.add(uiCheckbox, BorderLayout.EAST);
bonusCheckBoxes.add(uiCheckbox);
return uiOption;
}
代码示例来源:origin: nodebox/nodebox
public PortNotesRow(String notes) {
setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
notesLabel = new JLabel(notes);
notesLabel.setFont(Theme.SMALL_FONT);
notesLabel.setForeground(Theme.TEXT_NORMAL_COLOR);
notesLabel.setBorder(BorderFactory.createEmptyBorder(TOP_PADDING, 0, BOTTOM_PADDING, 0));
add(Box.createHorizontalStrut(PortView.LABEL_WIDTH + 10));
add(this.notesLabel);
add(Box.createHorizontalGlue());
setBorder(Theme.PARAMETER_NOTES_BORDER);
}
代码示例来源:origin: runelite/runelite
@Override
public void setDimmed(boolean dimmed)
{
super.setDimmed(dimmed);
if (dimmed)
{
leftLabel.setForeground(Color.GRAY);
rightLabel.setForeground(Color.GRAY);
centerLabel.setText(dimmedText);
}
else
{
leftLabel.setForeground(Color.WHITE);
rightLabel.setForeground(Color.WHITE);
centerLabel.setText(centerLabelText);
}
}
内容来源于网络,如有侵权,请联系作者删除!