Java Code Examples for javax.swing.JLabel#getBackground()
The following examples show how to use
javax.swing.JLabel#getBackground() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConnectionErrMessage.java From netbeans with Apache License 2.0 | 6 votes |
static HyperlinkPane create() { String url = NbBundle.getMessage(ConnectionErrMessage.class, "MSG_ErrDebugSessionLinkURL");//NOI18N String descr = NbBundle.getMessage(ConnectionErrMessage.class, "MSG_ErrDebugSessionLinkDescription");//NOI18N String text = "<a href=\""+url+"\">"+descr+"</a>";//NOI18N Font font = UIManager.getFont("Label.font");//NOI18N Color color = UIManager.getColor("Label.background"); if (font == null || color == null ) { JLabel lbl = new JLabel(); font = lbl.getFont(); color = lbl.getBackground(); } HyperlinkPane retval = new HyperlinkPane("<html><body style=\"font-size: " +//NOI18N font.getSize() + "pt; font-family: " + font.getName() + ";\">" + text + "</body></html>");//NOI18N retval.setBackground(color);//NOI18N retval.setEditable(false); retval.setFocusable(false); return retval; }
Example 2
Source File: ExportToGURPSCalculatorCommand.java From gcs with Mozilla Public License 2.0 | 6 votes |
private void showResult(boolean success) { String message = success ? I18n.Text("Export to GURPS Calculator was successful.") : I18n.Text("There was an error exporting to GURPS Calculator. Please try again later."); String key = Preferences.getInstance().getGURPSCalculatorKey(); if (key == null || !key.matches("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89ab][0-9a-fA-F]{3}-[0-9a-fA-F]{12}")) { message = String.format(I18n.Text("You need to set a valid GURPS Calculator Key in sheet preferences.<br><a href='%s'>Click here</a> for more information."), OutputPreferences.GURPS_CALCULATOR_URL); } JLabel styleLabel = new JLabel(); Font font = styleLabel.getFont(); Color color = styleLabel.getBackground(); JEditorPane messagePane = new JEditorPane("text/html", "<html><body style='font-family:" + font.getFamily() + ";font-weight:" + (font.isBold() ? "bold" : "normal") + ";font-size:" + font.getSize() + "pt;background-color: rgb(" + color.getRed() + "," + color.getGreen() + "," + color.getBlue() + ");'>" + message + "</body></html>"); messagePane.setEditable(false); messagePane.setBorder(null); messagePane.addHyperlinkListener(event -> { if (Desktop.isDesktopSupported() && event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { URL url = event.getURL(); try { Desktop.getDesktop().browse(url.toURI()); } catch (IOException | URISyntaxException exception) { WindowUtils.showError(null, MessageFormat.format(I18n.Text("Unable to open {0}"), url.toExternalForm())); } } }); JOptionPane.showMessageDialog(Command.getFocusOwner(), messagePane, success ? I18n.Text("Success") : I18n.Text("Error"), success ? JOptionPane.INFORMATION_MESSAGE : JOptionPane.ERROR_MESSAGE); }
Example 3
Source File: WindowsLabelUI.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) { int mnemonicIndex = l.getDisplayedMnemonicIndex(); // W2K Feature: Check to see if the Underscore should be rendered. if (WindowsLookAndFeel.isMnemonicHidden() == true) { mnemonicIndex = -1; } if ( UIManager.getColor("Label.disabledForeground") instanceof Color && UIManager.getColor("Label.disabledShadow") instanceof Color) { g.setColor( UIManager.getColor("Label.disabledShadow") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor( UIManager.getColor("Label.disabledForeground") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX, textY); } else { Color background = l.getBackground(); g.setColor(background.brighter()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor(background.darker()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX, textY); } }
Example 4
Source File: ToolSelectorPanel.java From chipster with MIT License | 5 votes |
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel comp = (JLabel)super.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus); Color circleColor = ((ToolCategory)(list.getModel().getElementAt(index))).getColor(); if (circleColor == null) { circleColor = comp.getBackground(); } comp.setIcon(new ColoredCircleIcon(circleColor)); return this; }
Example 5
Source File: WindowsLabelUI.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) { int mnemonicIndex = l.getDisplayedMnemonicIndex(); // W2K Feature: Check to see if the Underscore should be rendered. if (WindowsLookAndFeel.isMnemonicHidden() == true) { mnemonicIndex = -1; } if ( UIManager.getColor("Label.disabledForeground") instanceof Color && UIManager.getColor("Label.disabledShadow") instanceof Color) { g.setColor( UIManager.getColor("Label.disabledShadow") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor( UIManager.getColor("Label.disabledForeground") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX, textY); } else { Color background = l.getBackground(); g.setColor(background.brighter()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor(background.darker()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX, textY); } }
Example 6
Source File: WindowsLabelUI.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) { int mnemonicIndex = l.getDisplayedMnemonicIndex(); // W2K Feature: Check to see if the Underscore should be rendered. if (WindowsLookAndFeel.isMnemonicHidden() == true) { mnemonicIndex = -1; } if ( UIManager.getColor("Label.disabledForeground") instanceof Color && UIManager.getColor("Label.disabledShadow") instanceof Color) { g.setColor( UIManager.getColor("Label.disabledShadow") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor( UIManager.getColor("Label.disabledForeground") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX, textY); } else { Color background = l.getBackground(); g.setColor(background.brighter()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor(background.darker()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX, textY); } }
Example 7
Source File: WindowsLabelUI.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) { int mnemonicIndex = l.getDisplayedMnemonicIndex(); // W2K Feature: Check to see if the Underscore should be rendered. if (WindowsLookAndFeel.isMnemonicHidden() == true) { mnemonicIndex = -1; } if ( UIManager.getColor("Label.disabledForeground") instanceof Color && UIManager.getColor("Label.disabledShadow") instanceof Color) { g.setColor( UIManager.getColor("Label.disabledShadow") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor( UIManager.getColor("Label.disabledForeground") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX, textY); } else { Color background = l.getBackground(); g.setColor(background.brighter()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor(background.darker()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX, textY); } }
Example 8
Source File: WindowsLabelUI.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) { int mnemonicIndex = l.getDisplayedMnemonicIndex(); // W2K Feature: Check to see if the Underscore should be rendered. if (WindowsLookAndFeel.isMnemonicHidden() == true) { mnemonicIndex = -1; } if ( UIManager.getColor("Label.disabledForeground") instanceof Color && UIManager.getColor("Label.disabledShadow") instanceof Color) { g.setColor( UIManager.getColor("Label.disabledShadow") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor( UIManager.getColor("Label.disabledForeground") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX, textY); } else { Color background = l.getBackground(); g.setColor(background.brighter()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor(background.darker()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX, textY); } }
Example 9
Source File: WindowsLabelUI.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) { int mnemonicIndex = l.getDisplayedMnemonicIndex(); // W2K Feature: Check to see if the Underscore should be rendered. if (WindowsLookAndFeel.isMnemonicHidden() == true) { mnemonicIndex = -1; } if ( UIManager.getColor("Label.disabledForeground") instanceof Color && UIManager.getColor("Label.disabledShadow") instanceof Color) { g.setColor( UIManager.getColor("Label.disabledShadow") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor( UIManager.getColor("Label.disabledForeground") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX, textY); } else { Color background = l.getBackground(); g.setColor(background.brighter()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor(background.darker()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX, textY); } }
Example 10
Source File: WindowsLabelUI.java From hottub with GNU General Public License v2.0 | 5 votes |
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) { int mnemonicIndex = l.getDisplayedMnemonicIndex(); // W2K Feature: Check to see if the Underscore should be rendered. if (WindowsLookAndFeel.isMnemonicHidden() == true) { mnemonicIndex = -1; } if ( UIManager.getColor("Label.disabledForeground") instanceof Color && UIManager.getColor("Label.disabledShadow") instanceof Color) { g.setColor( UIManager.getColor("Label.disabledShadow") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor( UIManager.getColor("Label.disabledForeground") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX, textY); } else { Color background = l.getBackground(); g.setColor(background.brighter()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor(background.darker()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX, textY); } }
Example 11
Source File: WindowsLabelUI.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) { int mnemonicIndex = l.getDisplayedMnemonicIndex(); // W2K Feature: Check to see if the Underscore should be rendered. if (WindowsLookAndFeel.isMnemonicHidden() == true) { mnemonicIndex = -1; } if ( UIManager.getColor("Label.disabledForeground") instanceof Color && UIManager.getColor("Label.disabledShadow") instanceof Color) { g.setColor( UIManager.getColor("Label.disabledShadow") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor( UIManager.getColor("Label.disabledForeground") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX, textY); } else { Color background = l.getBackground(); g.setColor(background.brighter()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor(background.darker()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX, textY); } }
Example 12
Source File: WindowsLabelUI.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) { int mnemonicIndex = l.getDisplayedMnemonicIndex(); // W2K Feature: Check to see if the Underscore should be rendered. if (WindowsLookAndFeel.isMnemonicHidden() == true) { mnemonicIndex = -1; } if ( UIManager.getColor("Label.disabledForeground") instanceof Color && UIManager.getColor("Label.disabledShadow") instanceof Color) { g.setColor( UIManager.getColor("Label.disabledShadow") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor( UIManager.getColor("Label.disabledForeground") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX, textY); } else { Color background = l.getBackground(); g.setColor(background.brighter()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor(background.darker()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX, textY); } }
Example 13
Source File: WindowsLabelUI.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) { int mnemonicIndex = l.getDisplayedMnemonicIndex(); // W2K Feature: Check to see if the Underscore should be rendered. if (WindowsLookAndFeel.isMnemonicHidden() == true) { mnemonicIndex = -1; } if ( UIManager.getColor("Label.disabledForeground") instanceof Color && UIManager.getColor("Label.disabledShadow") instanceof Color) { g.setColor( UIManager.getColor("Label.disabledShadow") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor( UIManager.getColor("Label.disabledForeground") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX, textY); } else { Color background = l.getBackground(); g.setColor(background.brighter()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor(background.darker()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX, textY); } }
Example 14
Source File: WindowsLabelUI.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) { int mnemonicIndex = l.getDisplayedMnemonicIndex(); // W2K Feature: Check to see if the Underscore should be rendered. if (WindowsLookAndFeel.isMnemonicHidden() == true) { mnemonicIndex = -1; } if ( UIManager.getColor("Label.disabledForeground") instanceof Color && UIManager.getColor("Label.disabledShadow") instanceof Color) { g.setColor( UIManager.getColor("Label.disabledShadow") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor( UIManager.getColor("Label.disabledForeground") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX, textY); } else { Color background = l.getBackground(); g.setColor(background.brighter()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor(background.darker()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX, textY); } }
Example 15
Source File: WindowsLabelUI.java From JDKSourceCode1.8 with MIT License | 5 votes |
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) { int mnemonicIndex = l.getDisplayedMnemonicIndex(); // W2K Feature: Check to see if the Underscore should be rendered. if (WindowsLookAndFeel.isMnemonicHidden() == true) { mnemonicIndex = -1; } if ( UIManager.getColor("Label.disabledForeground") instanceof Color && UIManager.getColor("Label.disabledShadow") instanceof Color) { g.setColor( UIManager.getColor("Label.disabledShadow") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor( UIManager.getColor("Label.disabledForeground") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX, textY); } else { Color background = l.getBackground(); g.setColor(background.brighter()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor(background.darker()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX, textY); } }
Example 16
Source File: WindowsLabelUI.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) { int mnemonicIndex = l.getDisplayedMnemonicIndex(); // W2K Feature: Check to see if the Underscore should be rendered. if (WindowsLookAndFeel.isMnemonicHidden() == true) { mnemonicIndex = -1; } if ( UIManager.getColor("Label.disabledForeground") instanceof Color && UIManager.getColor("Label.disabledShadow") instanceof Color) { g.setColor( UIManager.getColor("Label.disabledShadow") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor( UIManager.getColor("Label.disabledForeground") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX, textY); } else { Color background = l.getBackground(); g.setColor(background.brighter()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor(background.darker()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX, textY); } }
Example 17
Source File: WindowsLabelUI.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) { int mnemonicIndex = l.getDisplayedMnemonicIndex(); // W2K Feature: Check to see if the Underscore should be rendered. if (WindowsLookAndFeel.isMnemonicHidden() == true) { mnemonicIndex = -1; } if ( UIManager.getColor("Label.disabledForeground") instanceof Color && UIManager.getColor("Label.disabledShadow") instanceof Color) { g.setColor( UIManager.getColor("Label.disabledShadow") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor( UIManager.getColor("Label.disabledForeground") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX, textY); } else { Color background = l.getBackground(); g.setColor(background.brighter()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor(background.darker()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX, textY); } }
Example 18
Source File: WindowsLabelUI.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) { int mnemonicIndex = l.getDisplayedMnemonicIndex(); // W2K Feature: Check to see if the Underscore should be rendered. if (WindowsLookAndFeel.isMnemonicHidden() == true) { mnemonicIndex = -1; } if ( UIManager.getColor("Label.disabledForeground") instanceof Color && UIManager.getColor("Label.disabledShadow") instanceof Color) { g.setColor( UIManager.getColor("Label.disabledShadow") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor( UIManager.getColor("Label.disabledForeground") ); SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, textX, textY); } else { Color background = l.getBackground(); g.setColor(background.brighter()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX + 1, textY + 1); g.setColor(background.darker()); SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, textX, textY); } }