本文整理了Java中javax.swing.JLabel.setBackground()
方法的一些代码示例,展示了JLabel.setBackground()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLabel.setBackground()
方法的具体详情如下:
包路径:javax.swing.JLabel
类名称:JLabel
方法名:setBackground
暂无
代码示例来源:origin: jersey/jersey
@Override
public void run() {
label.setBackground(PROGRESS_COLOR);
label.setToolTipText("Running...");
label.setBorder(javax.swing.BorderFactory.createLineBorder(new Color(0, 0, 0)));
label.setOpaque(true);
messagePanel.add(label);
messagePanel.revalidate();
}
});
代码示例来源:origin: dcevm/dcevm
private JComponent getBanner() {
try {
BufferedImage img = ImageIO.read(getClass().getResource("splash.png"));
JLabel title = new JLabel(new ImageIcon(img));
title.setPreferredSize(new Dimension(img.getWidth() + 10, img.getHeight()));
title.setOpaque(true);
title.setBackground(new Color(238, 238, 255));
return title;
} catch (Exception ignore) {
}
return new JLabel();
}
代码示例来源:origin: runelite/runelite
avatarAndRight.setPreferredSize(new Dimension(0, 56));
JLabel avatar = new JLabel();
JLabel titleLabel = new JLabel(item.getTitle());
titleLabel.setFont(FontManager.getRunescapeSmallFont());
titleLabel.setBackground(null);
titleLabel.setForeground(darkerForeground);
titleLabel.setPreferredSize(new Dimension(CONTENT_WIDTH - TIME_WIDTH, 0));
JLabel timeLabel = new JLabel(durationToString(duration));
timeLabel.setFont(FontManager.getRunescapeSmallFont());
timeLabel.setForeground(darkerForeground);
代码示例来源:origin: apache/ignite
/**
* Add name and value labels.
*
* @param c Component.
* @param name Name.
* @param val Value.
* @param border Border.
*/
private void addAboutItem(JComponent c, String name, Object val, Border border) {
String v = val != null ? val.toString() : "n/a";
String tip = String.format("<html><b>%s</b> ➯ %s</html>", name, val);
JLabel lb = new JLabel(name);
lb.setToolTipText(tip);
JLabel field = new JLabel(v);
field.setOpaque(true);
field.setBackground(Color.WHITE);
field.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(VALUE_BORDER_COLOR, 1),
BorderFactory.createEmptyBorder(0, 3, 0, 3)));
field.setToolTipText(tip);
if (border != null)
field.setBorder(border);
c.add(lb, gbcLicenseLabel());
c.add(field, gbcLicenseField());
}
代码示例来源: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: libgdx/libgdx
public void actionPerformed (ActionEvent event) {
FileDialog dialog = new FileDialog(editor, "Select Image", FileDialog.LOAD);
if (lastDir != null) dialog.setDirectory(lastDir);
dialog.setVisible(true);
final String file = dialog.getFile();
final String dir = dialog.getDirectory();
if (dir == null || file == null || file.trim().length() == 0) return;
lastDir = dir;
try {
final FileHandle absolute = Gdx.files.absolute(dir + file);
final BufferedImage read = ImageIO.read(absolute.read());
final Image scaledInstance = read.getScaledInstance(100, -1, Image.SCALE_SMOOTH);
final ImageIcon image = new ImageIcon(scaledInstance);
JLabel previewImage = new JLabel(image);
previewImage.setOpaque(true);
previewImage.setBackground(Color.MAGENTA);
buildImagePanel(previewImage, absolute.file());
} catch (IOException e) {
e.printStackTrace();
}
}
代码示例来源: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.setBackground(myEntry.getBackground());
代码示例来源:origin: pentaho/mondrian
String propertyName = tableModel.getRowName(row);
stringRenderer.setOpaque(false);
stringRenderer.setToolTipText(null);
stringRenderer.setBackground(Color.white);
"Select the Join/Table object from Schema tree to "
+ "edit."));
stringRenderer.setOpaque(true);
stringRenderer.setBackground(Color.LIGHT_GRAY);
return stringRenderer;
stringRenderer.setOpaque(true);
stringRenderer.setBackground(new java.awt.Color(221, 221, 221));
if (isSelected && hasFocus) {
table.editCellAt(row, 1);
代码示例来源:origin: libgdx/libgdx
public void actionPerformed (ActionEvent event) {
FileDialog dialog = new FileDialog(editor, "Select Image", FileDialog.LOAD);
if (lastDir != null) dialog.setDirectory(lastDir);
dialog.setVisible(true);
final String file = dialog.getFile();
final String dir = dialog.getDirectory();
if (dir == null || file == null || file.trim().length() == 0) return;
lastDir = dir;
try {
final FileHandle absolute = Gdx.files.absolute(dir + file);
final BufferedImage read = ImageIO.read(absolute.read());
final Image scaledInstance = read.getScaledInstance(100, -1, Image.SCALE_SMOOTH);
final ImageIcon image = new ImageIcon(scaledInstance);
JLabel previewImage = new JLabel(image);
previewImage.setOpaque(true);
previewImage.setBackground(Color.MAGENTA);
buildImagePanel(previewImage, absolute.file());
} catch (IOException e) {
e.printStackTrace();
}
}
代码示例来源:origin: fossasia/neurolab-desktop
statusLabel = new JLabel("mute");
statusLabel.setBackground(new Color(255,0,0));
代码示例来源:origin: RaiMan/SikuliX2
pBox.setLayout(new BoxLayout(pBox, BoxLayout.Y_AXIS));
pBox.setBackground(Color.white);
status.setOpaque(true);
status.setBackground(Color.white);
status.setFont(new Font(Font.MONOSPACED, Font.PLAIN, statusFontHeight));
status.setText(" , ");
代码示例来源:origin: jersey/jersey
jLabel1 = new javax.swing.JLabel();
requestCountField = new javax.swing.JTextField();
syncRadio = new javax.swing.JRadioButton();
asyncRadio = new javax.swing.JRadioButton();
uriField = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
runButton = new javax.swing.JButton();
messagePanel = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
jLabel3.setBackground(new java.awt.Color(255, 255, 0));
jLabel3.setText(" ");
jLabel3.setToolTipText("Running...");
jLabel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
jLabel3.setOpaque(true);
messagePanel.add(jLabel3);
jLabel4.setBackground(new java.awt.Color(255, 255, 0));
jLabel4.setText(" ");
jLabel4.setToolTipText("Running...");
jLabel4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
jLabel4.setOpaque(true);
messagePanel.add(jLabel4);
代码示例来源:origin: igvteam/igv
private JLabel createMessageField(Color bg, Font font) {
JLabel messageField = new JLabel();
messageField.setBackground(bg);
messageField.setFont(font);
messageField.setBorder(BorderFactory.createLineBorder(Color.black));
return messageField;
}
代码示例来源:origin: UNIVALI-LITE/Portugol-Studio
@Override
public void mouseEntered(MouseEvent e)
{
JLabel rotulo = (JLabel) e.getSource();
rotulo.setBackground(ColorController.COR_DESTAQUE);
rotulo.setOpaque(true);
//rotulo.setFont(rotulo.getFont().deriveFont(Font.BOLD));
}
代码示例来源:origin: jersey/jersey
addButton = new javax.swing.JButton();
javax.swing.JPanel jPanel1 = new javax.swing.JPanel();
connectionStatusLabel = new javax.swing.JLabel();
startStopButton = new javax.swing.JButton();
javax.swing.JScrollPane jScrollPane2 = new javax.swing.JScrollPane();
jPanel4 = new javax.swing.JPanel();
twitterCheckbox = new javax.swing.JCheckBox();
twitterColorLabel = new javax.swing.JLabel();
testColorLabel = new javax.swing.JLabel();
testCheckbox = new javax.swing.JCheckBox();
twitterCheckbox.setText("Twitter aggregator");
twitterColorLabel.setBackground(new java.awt.Color(85, 170, 0));
twitterColorLabel.setText(" ");
twitterColorLabel.setOpaque(true);
testColorLabel.setBackground(new java.awt.Color(0, 85, 170));
testColorLabel.setText(" ");
testColorLabel.setOpaque(true);
代码示例来源:origin: Killerardvark/CryodexSource
public JPanel getWarningPane() {
if(warningPane == null){
warningPane = new JPanel();
warningPane.setVisible(false);
warningLabel = new JLabel();
warningPane.add(warningLabel);
warningPane.setBackground(Color.orange);
warningLabel.setBackground(Color.orange);
Font font = new Font("Courier", Font.BOLD,15);
warningLabel.setFont(font);
}
return warningPane;
}
代码示例来源:origin: UNIVALI-LITE/Portugol-Studio
@Override
public void mouseExited(MouseEvent e)
{
JLabel rotulo = (JLabel) e.getSource();
rotulo.setBackground(ColorController.COR_PRINCIPAL);
rotulo.setOpaque(false);
//rotulo.setFont(rotulo.getFont().deriveFont(Font.PLAIN));
}
};
代码示例来源:origin: apache/pdfbox
@Override
public Component getTableCellRendererComponent(
JTable jTable, Object o, boolean b, boolean b2, int i, int i2)
{
JLabel colorBar = new JLabel();
colorBar.setOpaque(true);
colorBar.setBackground((Color) o);
return colorBar;
}
}
代码示例来源:origin: cytoscape/application
/**
* Initializes the label.
*/
private void initLabel() {
floatLabel = new JLabel(getTitle());
floatLabel.setFont(new Font("SansSerif", Font.PLAIN, 12));
floatLabel.setBackground(FLOAT_PANEL_COLOR);
floatLabel.setBorder(new EmptyBorder(0, 5, 0, 0));
}
内容来源于网络,如有侵权,请联系作者删除!