Change disabled JLabel text color

Hi all
I have some JLabels labelled black on grey color.
When I disable them, the text color is too close to th background color to keep them readable. Is there a way to change the disabled color of the text to keep it dark enough to be read?
Thanks

import java.awt.*;
import java.util.*;
import javax.swing.*;
public class Test {
    public static void main(String[] args) {
         UIDefaults uid = UIManager.getLookAndFeelDefaults();
         for(Iterator i = uid.keySet().iterator(); i.hasNext(); ) {
             String key = (String) i.next();
             if (key.startsWith("Label"))
                System.out.println(key);
         UIManager.put("Label.disabledForeground", new Color(0x80, 0x40, 0));
         JPanel contentPane = new JPanel();
         JLabel label1 = new JLabel("This one is enabled");
         label1.setOpaque(true);
         contentPane.add(label1);
         JLabel label2 = new JLabel("This one is disabled");
         label2.setOpaque(true);
         label2.setEnabled(false);
         contentPane.add(label2);
         final JFrame f = new JFrame();
         f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         f.setContentPane(contentPane);
         f.pack();
         SwingUtilities.invokeLater(new Runnable(){
            public void run() {
                f.setLocationRelativeTo(null);
                f.setVisible(true);
}

Similar Messages

  • How can I change the default text color (black to blue) in Mail on Mountain Lion

    How can I change the default text color (black to blue) in Mail on out going email with Mountain Lion

    There really aren't default outgoing font settings. They are only there for viewing. A workaround I have seen mentioned is to start you signature with the font style you want to use. When you start your message, click in that first part of your signature.
    Something like
    defaults
    Signature

  • In Acrobat 8 Professional, how can I change the typewriter text color?

    I tried selecting the text then pressing Ctrl-E but the text properties toolbar that appears says, "No current selection." I tried this method another user suggested:
    "1. Use the text box tool to type some text, then select the text
    2. Use the properties bar, ctrl-E, or View > Toolbars > Properties Bar, to change the color of the font
    3. Highlight the text, not the text box and copy the text.
    4. Click on the typewriter tool and type some text.
    5. Click on the comments menu and select "Show Comments List", in the comments list you should see the typewriter entry from step 4 above.
    6. Highlight the typewriter text in the comments window then paste the copied text from step 3 above.  It should paste with the color selected in the properties bar.
    7. Right click an area of the typewriter entry in the comments list, and choose properties.
    8. On the General tab check the "Make Properties Default" Check box and click OK.
    All new typewriter entries should now use this new font color. "
    But when I get to STEP #2 the text properties toolbar that appears has all the options to edit the text shaded so I cannot select the option to change the text color. Any help would be appreciated!

    There really aren't default outgoing font settings. They are only there for viewing. A workaround I have seen mentioned is to start you signature with the font style you want to use. When you start your message, click in that first part of your signature.
    Something like
    defaults
    Signature

  • Change Icon Label Text Color

    So, I wanted to change the Finder Window background color to black. But when I do so, the text for the labels of the icons become un-readable. See picture.
    So I wanted to change the Label Text to white or some other lighter color. I'm surprised Mac OS X did not do it automatically. How do I change it?

    AFAIK, you can't. All I can suggest is use one of Apple's Desktop pictures and be done with it.

  • How to change the links text color?

    could any one tell me if it's possible to change the link text's color? instead we stuck with the defaut theme asigned color.

    Ok Looking to do this manually I don't see all that you suggest I need to see.
    .Body {
    color: #181c01;
    font-family: 'Palatino-Roman', 'Palatino', 'serif';
    font-size: 14px;
    font-style: normal;
    font-variant: normal;
    font-weight: normal;
    letter-spacing: 0;
    line-height: 19px;
    margin-bottom: 0px;
    margin-left: 0px;
    margin-right: 0px;
    margin-top: 0px;
    opacity: 1.00;
    padding-bottom: 0px;
    padding-top: 0px;
    text-align: left;
    text-decoration: none;
    text-indent: 0px;
    text-transform: none;
    .Header {
    color: #6a6f75;
    font-family: 'Palatino-Bold', 'Palatino', 'serif';
    font-size: 29px;
    font-style: normal;
    font-variant: normal;
    font-weight: bold;
    letter-spacing: 0.16em;
    line-height: 38px;
    margin-bottom: 0px;
    margin-left: 0px;
    margin-right: 0px;
    margin-top: 0px;
    opacity: 1.00;
    padding-bottom: 0px;
    padding-top: 0px;
    text-align: center;
    text-decoration: none; NOTE THIS
    text-indent: 0px;
    text-transform: uppercase;
    .Normal {
    padding: 4px;
    .graphicgeneric_body_textbox_styledefault {
    background: transparent;
    float: none;
    margin: 0px;
    opacity: 1.00;
    .graphicgeneric_header_textbox_styledefault {
    background: transparent;
    float: none;
    margin: 0px;
    opacity: 1.00;
    .graphictextbox_layout_styledefault {
    padding: 4px;
    .graphictextbox_styledefault {
    background: transparent;
    float: none;
    margin: 0px;
    opacity: 1.00;
    div {
    overflow: visible;
    img {
    border: none;
    .InlineBlock {display: inline; }
    .InlineBlock {display: inline-block; }
    .tinyText {
    font-size: 1px;
    This is the welcome page css file, not the index file.
    On my page I have white background, black text, when the arrow points to the link text it turns light brown, I am not so concerned about anything except the link text standing out in a differnt color, initially.
    I am leaning quite abit.
    So what do I do now
    Thanks
    Moncrief

  • Is it possible to change the selectedTab text color in SPRY Tabs?

    Was working with SPRY tabs and the client would like the font color to change to white on roll over and select.
    Is this possible through simply adding a single line of code to the css file of the SPRY file under
    .TabbedPanelsTabSelected {
        height: 46px;
        width: 168px;
        background-color: #a7b9c3;
        color: #f7f7f7;
    as you can see I already attempted to change the color and wasn't able to achieve the results on
    http://ebnerproductions.com/index22.html
    If it is possible, awesome, if not, I will replace with rollover images to get the desired result.
    Adam Ebner
    Thank you again to everyone in the forum as you have all helped me big time in the last couple of days!!!!!

    I've gone through the coding now for a couple of days and still cannot get the font color to change on select.
    I tried to inserted the recommended
    <style>
    .TabbedPanelsTabSelected,
    .TabbedPanelsTabHover {
         color: #FFF;
    </style>
    coding that was offered earlier, and it did nothing....
    here is the CSS for my tabbed panels... PLEASE LET ME KNOW WHAT I HAVE DONE WRONG, OR FORGOT!!!!
    site is ... http://ebnerproductions.com/index22.html
    Here is the Spry css ....
    @charset "UTF-8";
    /* SpryTabbedPanels.css - version 0.4 - Spry Pre-Release 1.6.1 */
    /* Copyright (c) 2006. Adobe Systems Incorporated. All rights reserved. */
    /* Horizontal Tabbed Panels
    * The default style for a TabbedPanels widget places all tab buttons
    * (left aligned) above the content panel.
    /* This is the selector for the main TabbedPanels container. For our
    * default style, this container does not contribute anything visually,
    * but it is floated left to make sure that any floating or clearing done
    * with any of its child elements are contained completely within the
    * TabbedPanels container, to minimize any impact or undesireable
    * interaction with other floated elements on the page that may be used
    * for layout.
    * If you want to constrain the width of the TabbedPanels widget, set a
    * width on the TabbedPanels container. By default, the TabbedPanels widget
    * expands horizontally to fill up available space.
    * The name of the class ("TabbedPanels") used in this selector is not
    * necessary to make the widget function. You can use any class name you
    * want to style the TabbedPanels container.
    .TabbedPanels {
        margin: 0px;
        padding: 0px;
        float: left;
        clear: none;
        width: 810px; /* IE Hack to force proper layout when preceded by a paragraph. (hasLayout Bug)*/
        position: absolute;
        left: auto;
        top: auto;
        color: #666;   
    /* This is the selector for the TabGroup. The TabGroup container houses
    * all of the tab buttons for each tabbed panel in the widget. This container
    * does not contribute anything visually to the look of the widget for our
    * default style.
    * The name of the class ("TabbedPanelsTabGroup") used in this selector is not
    * necessary to make the widget function. You can use any class name you
    * want to style the TabGroup container.
    .TabbedPanelsTabGroup {
        margin: 0px;
        padding: 0px;
        width: 840px;
        color: #666;
    /* This is the selector for the TabbedPanelsTab. This container houses
    * the title for the panel. This is also the tab "button" that the user clicks
    * on to activate the corresponding content panel so that it appears on top
    * of the other tabbed panels contained in the widget.
    * For our default style, each tab is positioned relatively 1 pixel down from
    * where it wold normally render. This allows each tab to overlap the content
    * panel that renders below it. Each tab is rendered with a 1 pixel bottom
    * border that has a color that matches the top border of the current content
    * panel. This gives the appearance that the tab is being drawn behind the
    * content panel.
    * The name of the class ("TabbedPanelsTab") used in this selector is not
    * necessary to make the widget function. You can use any class name you want
    * to style this tab container.
    .TabbedPanelsTab {
        position: relative;
        top: 0px;
        float: left;
        padding: 0px;
        margin: 0px;
        list-style: none;
        -moz-user-select: none;
        -khtml-user-select: none;
        cursor: pointer;
        height: 41px;
        width: 158px;
        outline:none;
        text-align: center;
        font-family: Archer-Medium-Pro.otf;
        font-size: 1.4em;
        font-weight: normal;
        color: #666;
        font-style: normal;
        padding-top: 8px;
        -moz-border-top-right-radius: 8px;
        -moz-border-top-left-radius: 8px;/* for older versions of Firefox) */
        -webkit-border-top-right-radius: 8px;
        -webkit-border-top-left-radius: 8px;/* for older versions of Safari and Chrome */
        border-top-right-radius: 8px;
        border-top-left-radius: 8px;/* Newer browsers */
    /* This selector is an example of how to change the appearnce of a tab button
    * container as the mouse enters it. The class "TabbedPanelsTabHover" is
    * programatically added and removed from the tab element as the mouse enters
    * and exits the container.
    .TabbedPanelsTabHover {
        background-color: #EEE;
        color: #FFF;
        width: 158px;
        outline:none;
    /* This selector is an example of how to change the appearance of a tab button
    * container after the user has clicked on it to activate a content panel.
    * The class "TabbedPanelsTabSelected" is programatically added and removed
    * from the tab element as the user clicks on the tab button containers in
    * the widget.
    * As mentioned above, for our default style, tab buttons are positioned
    * 1 pixel down from where it would normally render. When the tab button is
    * selected, we change its bottom border to match the background color of the
    * content panel so that it looks like the tab is part of the content panel.
    .TabbedPanelsTabSelected {
        height: 41px;
        width: 158px;
        background-color: #a7b9c3;
        font: Archer-Pro-Medium;
        color: #FFF;
        outline:none;
    /* This selector is an example of how to make a link inside of a tab button
    * look like normal text. Users may want to use links inside of a tab button
    * so that when it gets focus, the text *inside* the tab button gets a focus
    * ring around it, instead of the focus ring around the entire tab.
    .TabbedPanelsTab a {
        color: #666;
        text-decoration: none;
        outline:none;
    /* This is the selector for the ContentGroup. The ContentGroup container houses
    * all of the content panels for each tabbed panel in the widget. For our
    * default style, this container provides the background color and borders that
    * surround the content.
    * The name of the class ("TabbedPanelsContentGroup") used in this selector is
    * not necessary to make the widget function. You can use any class name you
    * want to style the ContentGroup container.
    .TabbedPanelsContentGroup {
        clear: both;
        background-color: ;
        outline:none;
    /* This is the selector for the Content panel. The Content panel holds the
    * content for a single tabbed panel. For our default style, this container
    * provides some padding, so that the content is not pushed up against the
    * widget borders.
    * The name of the class ("TabbedPanelsContent") used in this selector is
    * not necessary to make the widget function. You can use any class name you
    * want to style the Content container.
    .TabbedPanelsContent {
        padding: 0px;
    /* This selector is an example of how to change the appearnce of the currently
    * active container panel. The class "TabbedPanelsContentVisible" is
    * programatically added and removed from the content element as the panel
    * is activated/deactivated.
    .TabbedPanelsContentVisible {
    /* Vertical Tabbed Panels
    * The following rules override some of the default rules above so that the
    * TabbedPanels widget renders with its tab buttons along the left side of
    * the currently active content panel.
    * With the rules defined below, the only change that will have to be made
    * to switch a horizontal tabbed panels widget to a vertical tabbed panels
    * widget, is to use the "VTabbedPanels" class on the top-level widget
    * container element, instead of "TabbedPanels".
    /* This selector floats the TabGroup so that the tab buttons it contains
    * render to the left of the active content panel. A border is drawn around
    * the group container to make it look like a list container.
    .VTabbedPanels .TabbedPanelsTabGroup {
        float: left;
        width: 10em;
        height: 20em;
        background-color: #EEE;
        position: relative;
        border-top: solid 1px #999;
        border-right: solid 1px #999;
        border-left: solid 1px #CCC;
        border-bottom: solid 1px #CCC;
    /* This selector disables the float property that is placed on each tab button
    * by the default TabbedPanelsTab selector rule above. It also draws a bottom
    * border for the tab. The tab button will get its left and right border from
    * the TabGroup, and its top border from the TabGroup or tab button above it.
    .VTabbedPanels .TabbedPanelsTab {
        float: none;
        margin: 0px;
        border-top: none;
        border-left: none;
        border-right: none;
    /* This selector disables the float property that is placed on each tab button
    * by the default TabbedPanelsTab selector rule above. It also draws a bottom
    * border for the tab. The tab button will get its left and right border from
    * the TabGroup, and its top border from the TabGroup or tab button above it.
    .VTabbedPanels .TabbedPanelsTabSelected {
        background-color: #EEE;
    /* This selector floats the content panels for the widget so that they
    * render to the right of the tabbed buttons.
    .VTabbedPanels .TabbedPanelsContentGroup {
        clear: none;
        float: left;
        padding: 0px;
        width: 30em;
        height: 20em;
    Thank everyone again for all the help!

  • How do I change navigation bar text color?

    I want to change the color of the type in the navigation bar, as well as the line/bar below the type. How can I do this?

    there are many way to change navbar look-and-feel:
    1) by changing template XML, this requires XML knowledge and is a complex process.
    2) by changing navbar CSS in page source, this a bit easier but requires post editing.
    http://discussions.apple.com/thread.jspa?messageID=5186688&#5186688
    3) by javascript, this requires CSS and javascript knowledge:
    http://discussions.apple.com/thread.jspa?messageID=8638743&#8638743
    4) by manually build your own navbar as roddy and ot mentioned, this requires no knowledge of any kind but it is not very efficient; see my post here:
    http://discussions.apple.com/thread.jspa?messageID=8136472&#8136472
    5) by AJAX, this requires CSS, javascript and AJAX knowledge; I outlined it in my blog here:
    http://www.cyclosaurus.com/Home/CyclosaurusBlog/Entries/2009/9/10iWeb_NavBarWidget.html

  • Changing a JLabel text moves everything around -- and it shouldn't

    I have this problem where whenever I call setText() for this one JLabel, it moves everything around. It doesn't have anything to do with the length of the text, because if I replace it with the same exact string, it still moves stuff around.
    I understand it's really hard to troubleshoot these things w/o source code, but I was wondering if this is a problem someone has seen before?
    I'm not going to post my code just because it's too long and I won't ask anyone to go through it for me.
    Basically it is a JFrame with 2 JPanels laid out w/ GridBagLayout, and each JPanel has it's own GridBagLayout
    Thanks

    well, Ironically, while I was creating that code sample thing I figured out what was going on myself. I was confused because of some misdirection--- the issue was not with the JLabel, that was just where the symptoms showed.
    thanks anyway, and sorry for the delayed response -- i only work part time...

  • How to change the text color of a formLayoutColumnHeader ?

    Hi all,
    I'm working on a BSP on SAP NetWeaver 2004s and would need to change the (OTR) text color to red in a
    formLayoutColumnHeader, but there is no attribute about it. I searched for other threads and tried with the
    tag <font color=....>  before the OTR tag, but the tag is shown with the OTR text on the UI...
    Example:
        <phtmlb:formLayoutColumnHeader id   = "PublInfoGroupHeader"
                        text     = "<%= otr(xxxxxxxx) %>"  />
    Thx in advance, best regards.
    Angelo

    did you try
    text = "<font color='red'><%= otr(xxxxxxxx) %></font>"

  • Changing highlight text color / using Highlighters

    I've subclassed JTextArea, and among other things, am trying to add the functionality for drawing the active selection even when the TextArea doesn't have focus. I've overridden processFocusEvent like so:
    public void processFocusEvent(FocusEvent e){
            Highlighter h = this.getHighlighter();
             if (e.getID() == e.FOCUS_GAINED){
                //remove the inactive highlight
                h.removeAllHighlights();
            //this will put the selection highlight back in for us, among other things,
            //if we just gained focus.
            super.processFocusEvent(e);
            //now add the inactive-selection highlight if we just lost focus
            if (e.getID() == e.FOCUS_LOST){
                try {
                    h.addHighlight(
                            this.getSelectionStart(),
                            this.getSelectionEnd(),
                            new DefaultHighlighter.DefaultHighlightPainter(
                                new Color(212,212,212)
                } catch (Exception ex){
                    ex.printStackTrace();
        }and it works quite nicely. Notice that I draw the inactive selection gray.
    There's a slight problem with this: JTextArea doesn't treat the text in the highlighted section any differently, as opposed to how it would when the component is focused (i.e. rendering it in the highlighted text color). I'm guessing this is because it knows that it's not focused, and therefore assumes that there's no highlighting to be drawn. So as a result, all text in the text area is rendered in the same color --- the foreground color --- when the textArea doesn't have focus, regardless of what is being highlighted. For this reason, setSelectedTextColor() has no effect.
    But I want to be able to change the highlighted text color, since, in theory, the user's system could be configured to show text in the exact same gray that I'm highlighting with. I want to just be able to set it to be white or black.
    I am rather averse to using a TextPane, since what I'm writing is designed to edit plain text, and a TextArea has many wheels that I don't want to reinvent, like setTabSize(), for example.
    Clearly, there is code already in place somewhere to draw text a different color for highlighted portions of a TextArea. Is there some way I could perhaps trick only the drawing code into thinking that it has focus? What is the cleanest way to accomplish what I want, i.e. the way that involves rewriting the least amount of functionality?
    Any suggestions/leads would be greatly appreciated.

    Here's a better way to keep the selection visible. All those hard-coded colors are a big no-no, but this is just to demonstrate the technique.
    import java.awt.Color;
    import javax.swing.text.DefaultCaret;
    import javax.swing.text.Highlighter;
    import javax.swing.text.DefaultHighlighter;
    * usage:
    * textComponent.setCaret(new GhostCaret());
    public class GhostCaret extends DefaultCaret
      private static final Highlighter.HighlightPainter unfocusedPainter =
          new DefaultHighlighter.DefaultHighlightPainter(new Color(230, 230, 210));
      private boolean isFocused;
      protected Highlighter.HighlightPainter getSelectionPainter()
        return isFocused ? SimpleHighlighter.defaultPainter : unfocusedPainter;
      public void setSelectionVisible(boolean hasFocus)
        if (hasFocus != isFocused)
          isFocused = hasFocus;
          super.setSelectionVisible(false);
          super.setSelectionVisible(true);
          getComponent().setSelectedTextColor(isFocused ? Color.WHITE : Color.BLACK);
    }

  • Linked text color

    Can I make a link to the text in accordion panel tab?
    If I can, how can I change the linked text color?
    I needed to know this desperately.
    Can any one please teach me?
    Thanking you in advance.
    pepe12345

    I have just worked out the answer myself.
    I did not have to touch SpryAccordion.css at all.
    I just simply add link ( a and a:hover) text color in the div
    css.
    Thank you very much.

  • Background Text Color

    I have a problem with background text, particularly in yahoo, but other pages as well. The background color is a light, very light grey. I often have to highlight, or copy and past to be able to read.
    Is there a way to change these background text colors???
    Thanks

    Hi,
    Open System Preferences / Universal Accesss - Seeing.
    See if you have the Display set as "Whtie on black".
    Or, if the "User grayscale" box is selected, deselect that.
    Or, try move the Reduce or Increase contrast slider.
    Carolyn
    Message was edited by: Carolyn Samit

  • Ios7 Email text colors

    I am happy with ios7 overall except for the following issue that I am trying to find a way around
    When there is an email thread going on with several replies from multiple people the color of the email text in the history ( quoted text two or three threads older) gets very difficult to read.
    The very first reply is usually black and the older one becomes blue which is bad because it is the exact same color shade as the reply and delete buttons. However it gets worse. If you scroll down further and look at replies two or three threads older the color gets to a horrible flavor of green with inbetween blues.
    I find this not very annoying and I am unable to read. Things get way worse on the ipad than on the iphone.
    Is there a way to change the email text colors in the settings somewhere. I use my phone as a primary phone for my corporate email and hence using third party apps like yahoo or gmail will not solve the issue.
    Please help.

    Websites look wrong
    https://support.mozilla.com/en-US/kb/Websites%20look%20wrong
    Check and tell if its working.

  • Flash chat alternate text colors

    Anybody know how to alternate text colors in a Chat  i tried to use css but it changes all the text colors not just each message. Anybody know or point me in the right direction?

    Hi Mate,
    Send the Color value from
    As3     ---->> FMS Asc (color).
    As3  << ----- FMS
    Ex:
    Flash
    ns.call(privateMsg ,#00000,null)
    ASC
    newClient.privateMsg = function(color){
        application.list[user].call("privateMsg2",color);

  • Text Color in disabled text field

    Hi,
    In our application, The default rendered text in disabled fields is not visible properly. In order to improve the visibility we applied different color using content style for those fields.
    We did see the change in the fields after applying content-style. But it is a painful job to apply the content-style for each input field.
    Is there a way to configure default text color in ADF which is applicable for all the disabled fields in the application?
    We also tried the option of setting the color using css in following manner:
    af|inputText::content{color:#333333;}
    But this didn't have any impact on the text color.
    Please let us know if we can achieve this through a single point fix in the code.
    Thanks
    Ravi

    Hi Dimitar,
    The :rtl is a special case, as is :ltr and :alias. These are always placed at the end and are purely for the engine, they do not generate any style class on the DOM whereas other peudo classes generate a p_AF<state> class on the MAIN DOM element, which is why you must place the class on them. For example:
    af|inputText:disabled::content becomes
    In the CSS: af_inputText.p_AFDisabled af_inputText_content
    In the HTML <span class="af_inputText p_AFDisabled"><input class="af_inputText_content">
    Regards,
    ~ Simon

Maybe you are looking for

  • Questions on Saving and mining data with Labview and DIAdem

    Hi, I am sampling two signals at 200k sampling rate. I am trying to save the data on harddisk and analyzing the data using DIAdem. If I save the data using mesurement file format .tdm and .lvm, the file size will be about 4 Gigabytes for only 10 mins

  • How to open fpx files

    how to open fpx files

  • Swished import

    I imported video from my iphone 3gs via iphoto and again through image capture and the video appears in imovie flatted out (the bride and her father look fat!) What I am doing wrong? GH

  • Where can I get Firefox portable 7.0 or 7.0.1 version for Mac/apple?

    My college's website requires version 5,6, or 7 of firefox to run. I think it be bad to downgrade so I'm trying to find where I can download a portable version safely.

  • Paragraphs and Bulleted List

    We are trying to format some text in a TextFrame that we add using javascripting (and InDesign Server CS3). Basically, this is what we would like to achieve: Some text goes here * First bullet point * Second bullet point * Third etc... Each line ends