本文整理了Java中javax.swing.JLabel.setOpaque()
方法的一些代码示例,展示了JLabel.setOpaque()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLabel.setOpaque()
方法的具体详情如下:
包路径:javax.swing.JLabel
类名称:JLabel
方法名:setOpaque
暂无
代码示例来源: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: libgdx/libgdx
public void addValue (final Value value) {
JLabel valueNameLabel = new JLabel(value.getName() + ":");
valuesPanel.add(valueNameLabel, new GridBagConstraints(0, -1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST,
GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
final JLabel valueValueLabel = new JLabel();
valuesPanel.add(valueValueLabel, new GridBagConstraints(1, -1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));
valueValueLabel.setOpaque(true);
if (value.getObject() instanceof java.awt.Color)
valueValueLabel.setIcon(getColorIcon((java.awt.Color)value.getObject()));
else
valueValueLabel.setText(value.toString());
valueValueLabel.addMouseListener(new MouseAdapter() {
public void mouseEntered (MouseEvent evt) {
valueValueLabel.setBackground(selectedColor);
}
public void mouseExited (MouseEvent evt) {
valueValueLabel.setBackground(null);
}
public void mouseClicked (MouseEvent evt) {
Object oldObject = value.getObject();
value.showDialog();
if (!value.getObject().equals(oldObject)) {
effect.setValues(values);
updateValues();
updateFont();
}
}
});
}
代码示例来源: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: libgdx/libgdx
public void addValue (final Value value) {
JLabel valueNameLabel = new JLabel(value.getName() + ":");
valuesPanel.add(valueNameLabel, new GridBagConstraints(0, -1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST,
GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
final JLabel valueValueLabel = new JLabel();
valuesPanel.add(valueValueLabel, new GridBagConstraints(1, -1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));
valueValueLabel.setOpaque(true);
if (value.getObject() instanceof java.awt.Color)
valueValueLabel.setIcon(getColorIcon((java.awt.Color)value.getObject()));
else
valueValueLabel.setText(value.toString());
valueValueLabel.addMouseListener(new MouseAdapter() {
public void mouseEntered (MouseEvent evt) {
valueValueLabel.setBackground(selectedColor);
}
public void mouseExited (MouseEvent evt) {
valueValueLabel.setBackground(null);
}
public void mouseClicked (MouseEvent evt) {
Object oldObject = value.getObject();
value.showDialog();
if (!value.getObject().equals(oldObject)) {
effect.setValues(values);
updateValues();
updateFont();
}
}
});
}
代码示例来源: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: 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: 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: kiegroup/optaplanner
int employeeIndex = 0;
for (Employee employee : employeeList) {
JLabel employeeLabel = new JLabel(employee.getLabel(), new TaskOrEmployeeIcon(employee), SwingConstants.LEFT);
employeeLabel.setOpaque(true);
employeeLabel.setToolTipText(employee.getToolText());
employeeLabel.setLocation(0, HEADER_ROW_HEIGHT + employeeIndex * ROW_HEIGHT);
JLabel timeLabel = new JLabel((hours < 10 ? "0" : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes);
timeLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
timeLabel.setLocation(x, 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: magefree/mage
public MyComboBoxEditor() {
label = new JLabel();
panel = new JPanel();
label.setOpaque(false);
label.setFont(new Font("Arial", Font.BOLD, 14));
label.setForeground(Color.BLACK);
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 2));
panel.add(label);
panel.setBackground(Color.BLUE);
}
代码示例来源: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: apache/pdfbox
JLabel lightest = new JLabel("lightest");
lightest.setFont(new Font(Font.MONOSPACED, Font.BOLD, 10));
JLabel darkest = new JLabel("darkest");
darkest.setFont(new Font(Font.MONOSPACED, Font.BOLD, 10));
JLabel midPoint = new JLabel("0.5");
midPoint.setFont(new Font(Font.MONOSPACED, Font.BOLD, 10));
labelTable.put(0, lightest);
colorBar = new JLabel();
colorBar.setOpaque(true);
gbc2.gridx = 2;
gbc2.weightx = 0.7;
代码示例来源: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: winder/Universal-G-Code-Sender
bottomTabbedPane = new javax.swing.JTabbedPane();
commandsPanel = new javax.swing.JPanel();
commandLabel = new javax.swing.JLabel();
commandTextField = new com.willwinder.universalgcodesender.uielements.components.CommandTextArea(backend);
consoleScrollPane = new javax.swing.JScrollPane();
opencloseButton = new javax.swing.JButton();
refreshButton = new javax.swing.JButton();
baudLabel = new javax.swing.JLabel();
portLabel = new javax.swing.JLabel();
firmwareLabel = new javax.swing.JLabel();
firmwareComboBox = new javax.swing.JComboBox();
activeStateLabel.setOpaque(true);
activeStateValueLabel.setOpaque(true);
内容来源于网络,如有侵权,请联系作者删除!