javax.swing.JLabel#getBackground ( )源码实例Demo

下面列出了javax.swing.JLabel#getBackground ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: ConnectionErrMessage.java
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;
}
 
源代码2 项目: gcs   文件: ExportToGURPSCalculatorCommand.java
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);
}
 
源代码3 项目: jdk1.8-source-analysis   文件: WindowsLabelUI.java
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);
    }
}
 
源代码4 项目: dragonwell8_jdk   文件: WindowsLabelUI.java
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);
    }
}
 
源代码5 项目: TencentKona-8   文件: WindowsLabelUI.java
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);
    }
}
 
源代码6 项目: jdk8u60   文件: WindowsLabelUI.java
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);
    }
}
 
源代码7 项目: JDKSourceCode1.8   文件: WindowsLabelUI.java
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);
    }
}
 
源代码8 项目: openjdk-jdk8u   文件: WindowsLabelUI.java
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);
    }
}
 
源代码9 项目: openjdk-jdk8u-backup   文件: WindowsLabelUI.java
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);
    }
}
 
源代码10 项目: openjdk-jdk9   文件: WindowsLabelUI.java
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);
    }
}
 
源代码11 项目: jdk8u-jdk   文件: WindowsLabelUI.java
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);
    }
}
 
源代码12 项目: hottub   文件: WindowsLabelUI.java
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);
    }
}
 
源代码13 项目: openjdk-8-source   文件: WindowsLabelUI.java
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);
    }
}
 
源代码14 项目: openjdk-8   文件: WindowsLabelUI.java
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);
    }
}
 
源代码15 项目: jdk8u_jdk   文件: WindowsLabelUI.java
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);
    }
}
 
源代码16 项目: jdk8u-jdk   文件: WindowsLabelUI.java
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);
    }
}
 
源代码17 项目: jdk8u-dev-jdk   文件: WindowsLabelUI.java
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);
    }
}
 
源代码18 项目: chipster   文件: ToolSelectorPanel.java
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;
}