Setting foreground font color on a JSpinner

I'm trying to edit the foreground font color on a JSpinner component.
spinner.setForeground(Color color) or
spinner.getEditor().setForeground(Color color) doesn't work
What does?
Best regards,
Helge Fredriksen

try:
      JSpinner.DefaultEditor editor=(JSpinner.DefaultEditor)spinner.getEditor();
      JFormattedTextField TF=(JFormattedTextField)editor.getTextField();
      TF.setForeground(myColor);;o)
V.V.

Similar Messages

  • How do you set the font color for a specific entire row inside a JTable?

    How do you set the font color for a specific entire row inside a JTable?
    I want to change the font color for only a couple of rows inside a JTable.
    I've seen some ways to possibly do this with an individual cell.
    Clarification on changing the font color in an individual cell would be helpful too if
    there is no easy way to do this for a row.

    hai,
    Try out with this piece of code.Create your table and assign the renderer to each column in the table.
    CellColorRenderer m_CellColorRenderer = new CellColorRenderer();
    for(int i=0;i<your_JTable.getColumnCount();i++)
    your_JTable.getColumnModel().getColumn(i).setCellRenderer(m_CellColorRenderer);
    class CellColorRenderer extends JLabel implements TableCellRenderer
    CellColorRenderer()     
    setOpaque(true);     
    setHorizontalAlignment(LEFT);
    setVerticalAlignment(CENTER);
    setBackground(Color.white);
    setForeground(Color.black);
    protected void setValue(Object value)
         setText((value == null) ? "" : value.toString());
    public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected, boolean hasFocus, int row,int column)
         if(isSelected == true)
              setForeground(Color.red);
         else
              setForeground(Color.black);
         setValue(value);
         return this;
    regards,
    bala

  • How to set foreground gradent color to label???

    using this i can set background gradentcolor to label. But how to set foreground gradentcolor to label???
    JLabel compname = new JLabel("ARDENT TECHNOLOGIES INC")
              protected void paintComponent(Graphics g)
                { int width = getWidth();
                int height = getHeight();
                GradientPaint paint = new GradientPaint(0, 0,  Color.blue, width, height, Color.green);
                Graphics2D g2d =(Graphics2D)g;
                g2d.setPaint(paint);
                g2d.fillRect(0, 0, width,height);           
                super.paintComponent(g); } };
                compname.setOpaque( false );Thanks in advance
    raja

    reply #3 looks interesting
    http://forum.java.sun.com/thread.jspa?forumID=257&threadID=481290

  • Setting the Font color.

    hello,
    Could someone tell me what the method is to change the Font color.

    Read the JComponent API. Check out the setForeground(...) method.

  • How to set default font color in Pages

    I don't know why. I did a standard clean install of iWork 08. In Pages, everytime I select to insert a text box, the color of the font defaults to brown rather than black. It's a pain to change it to black all the time. Also I noticed that when I select to insert a line, it also defaults to brown. Any thoughts on why this is happening as the default color and how to fix it?
    Also, almost evertime I do the option click on the text box icon to draw a text box, the cursor changes to the crosshair but the box allows me to draw the with size, but the length of the column automatically can't be drawn- it extends instead all the way off the bottom of the page. In other words I can't really draw the text box to the size I need. I'm new to Pages.

    Fix Your Fonts in Safari 6
    Some Safari 6 stuff
    TextExpander shell script snippet to set Safari 6 default fonts
    Safari 6 on Lion, text much smaller?
    Quickstyle - Canisbos
    Safari 6 default font way too small?

  • Setting Font/Color for ProgressMonitor

    Hi All,
    I am using ProgressMonitor something like this.
    pbar.setNote("Loading:"+f[index].getName()+ "  " +"with Operation of " + counter + "% complete");Where pbar is an instance of ProgressMonitor.Now we can see that setNote method inside ProgressMonitor String as an argument.I want to set the font and foreground color for the text inside.Any idea how to do that??
    Any help appreciated.
    Thanks in advance.
    regards,
    Viswanadh
    Edited by: TechnicalGuy7 on Apr 24, 2009 3:42 AM

    If the progress bar had a method to set a label, instead of just set text, then you could set that label with any font and colors that you wanted...
    If you really needed to set the font color, you would need to call setUI on the progress bar, and provide you own ProgressBarUI class.
    You could start with one of the UI classes provided, like BasicProgressBarUI and extend it and modify it as you wish.
    But this is really advanced...

  • Setting the global Font color for an application

    Hi,
    Can anyone tell me how I can set the default font colour for an application. I understand it involves using the UIManager class to somehow get/set the defaults but im stumped after that.
    Thanks in advance

    Since you really need to change foreground and etc. Use the following code to list all the resources that may set the font colors you want (the example only excludes background color resource, so it may set more than what you want, you need to pin point specific color resouces from the print out to suit your own need).
    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
    for(Iterator i = defaults.keySet().iterator(); i.hasNext();) {
    String name = (String)i.next();
    Object value = defaults.get(name);
    if (value instanceof ColorUIResource && !name.endsWith("Background")
    && !name.endsWith("background")) {
    System.out.println(name);
    UIManager.put(name, new ColorUIResource(Color.red));
    }

  • WLC AireOS 8.0 - how to set font-color for integrated webauth/weblogin?

    Hello,
    up to AireOS 7.6 I was able to set the font-color of the internal webauth/weblogin page using html-codes, for example like this:
    Headline: Welcome to our <font color="red">guest</font>-network!
    Message: You need a valid <font color="blue">user</font> to login.
    Now with AireOS 8.0 this doesn't work anymore. When I try to set a headline or message with font-tags I get "Error while setting headline." (or "...message.") when I hit apply. I have to remove the font-tag to save the weblogin page.
    #CLIWEB-6-CLIWEB_INVALID_HTML_TAGS_USED: [PA] cli_web_api.c:1748 The Customization message field has invalid html tags
    #CLIWEB-6-CLIWEB_INVALID_HTML_TAGS_USED: [PA] cli_web_api.c:1663 The Headline field has invalid html tags
    So, how can we now set different font colors/styles like in previous releases? Using external or uploading selfmade pages is not an option.
    Thanks,
    Chris

    Since your using code to change the default internal portal page look, its better for you just to create a custom webauth and upload that to the WLC.  That is how I do my implementations as its easier for me to create a new page than trying to mess around with the internal page.  As you can see, Cisco can change the way things work in every version.  It might just be the fact that they no longer are allowing html code to be inserted in the default webauth/passthrough page.
    Scott

  • Set font color for the JTextField

    I'm using JTextField in my project. However, can anybody teach me how to set the font color for the font in the JTextField to other color. The default font color is black. Any idea about this?

    JTextField field = new JTextField(20);
    field.setForeground(Color.blue);
    Good luck ;)

  • How to set font Color in Mail

    Sometime ago I set in Mail the default font to Arial, and the default font Size to 18, so when I write a new email these are my default font and size. But I could not set the font Color. How do I do this?

    Sounds like you have the Preferences toolbar closed on another selection.
    Go to Mail > Preferences and at the top right of the Preferences window is a clear pill shaped button.
    Selecting this button opens/closes the complete Preferences toolbar.

  • Setting font colors

    Is there a way to set the font color so that it isn't just white or whatever the default terminal font color is. I know there is a Font class, but I don't really understand how that works, whether I do Font.color and it will change the default changes or what. Can somebody direct me to more information that I can read up on, or if they know themselves. Thank you.

    I don't think fonts apply to terminals. They apply to GUIs, documents, and similar things that support different font types. I doubt there is a way using pure Java to change the color of text in a terminal, since that sounds like something that is OS specific.

  • Font Color Setting of Report Builder Previewer

    When I run the report via Report Builder (version 6.0.8.24.0), the color of font in the Previewer is rather pale though i have set the font color as Black. Would you please advise? Thanks.

    When I run the report via Report Builder (version
    6.0.8.24.0), the color of font in the Previewer is
    rather pale though i have set the font color as
    Black. Would you please advise? Thanks.The destype is "Previewer" and Desformat is "Wide" and mode is "Character"

  • Tab set font color

    I just downloaded the fix pack and have noticed that I am still unable to change the tab set tab font color.  Am I doing anything wrong?'
    Thanks,
    DD

    I believe what Purnima was speaking of was the Tab Background color properties.
    However, I believe there is an issue with the Label Over Color and Label Selected Color mapping properties of the Tab Set.
    Thanks.

  • Is this a valid work around for disabled TextField Font colors?

    We would like to change the font color in disabled TextFields.
    Since the AWT calls some native code that apparently overrides
    any call to setForeground(), so that the Foreground is always a
    light gray color in disabled TextFields I decided to override
    the paint() method. This works fine as listed below. The formula
    for setting the initial position for the drawString() method has
    worked for every Font/Size that I have tested, but I don't like
    the added literals (2 and +1) that I am needing to pass to have
    the string line up exactly as is displayed automatically.
    Is there another way to get these (x,y) values from method calls
    to the component, container or FontMetrics that I am missing?
    Also, does anyone see anything wrong with this to override the
    default implementation?
    Even though I do not call super.paint() in the event that
    the [enabled] field is true, the TextField still paints itself
    correctly with the appopriate Background and Foreground.
    If anyone knows why that is please let me know.
    Thanks
    public void setEnabled(boolean en) {
      enabled = en;
      super.setEnabled(enabled);
      if(enabled) {
        setBackground(defaultBackground);
        setForeground(defaultForeground);
      else {
        setBackground(disabledBackground);
        setForeground(disabledForeground);
    public void paint(Graphics g) {
      FontMetrics fm = this.getFontMetrics(this.getFont());
      // [enabled] is a private field that is set in the constructor
      // by calling this.isEnabled(), and by any call to the setEnabled()
      // method
      if(!enabled) {
        // clear the old string representation
        g.clearRect(0, 0, getSize().width, getSize().height);
        // set the font color to the defined [disabledForeground] Color
        g.setColor(disabledForeground);
        // draw the string in the desired Color instead of the default
        // disabled color of light gray
        g.drawString(getText(), 2, fm.getAscent()+1);
    }

    Walt, I tried that first, but due to the native call to draw
    the disabled TextField the setForeground() is useless.
    "The solution is platform dependent. A TextField might be painted entierly by native code. And then calls you make to the Graphics object will then have no effect at all. If you run your textfield in an applet in IE you will not see anything but the native TextField painting. The g.drawString, g.setColor or g.clearRect you call seems to be totaly ignored..."
    From the tests that I have done I was able to manipulate the
    the Graphics object in the paint() method to override the default
    representation of the TextField (I also tried this with a Button
    and it worked as well). I did run this in IE 5.0 and was able to
    get my modifications to work. Since the TextField that I am modifying
    must extend another class to inherit some default behavior
    I can not create a new TextField that implements a Panel, I thought
    about that until I was told that the TextField needs to extend an
    already existing class.
    I think that my solution should be fine. I was hoping to find out
    if anyone knows of a better way to determine the starting
    point for the drawString() method besides adding literals for the (x,y)
    attributes. If anyone knows a better way than my method please
    let me know.
    Thanks for the responses

  • GridControl: Column width and Font Color

    I'm having two problems with the GridControl in JBCL:
    1) I can't set the font color of the text in the gridcontrol. Is
    this possible? I tried setting the foreground color, but that
    didn't work. I'd also like to be able to set the background
    color for the headers.
    2) I have a gridcontrol connected to a queryDataSet. I set the
    column width of the columns in the query data set, and the
    columns in the gridcontrol expand up to about 100pixels. After
    that however, the don't get any larger (even when set to 300). I
    have 2 columns I want to span the entire width of the screen,
    but
    I can't get it working.
    Thanks for your help,
    Kevin
    null

    Can any one help us ?
    Thanks,
    Ramesh S.
    null

Maybe you are looking for