Can't set a component's color!???

Hi,
I can't figure out what I'm doing wrong here:
Scrollbar sb = new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, 255);
this.add(sb);
sb.setBounds(20, 20, 15, 200);
sb.setForeground(Color.BLACK);
sb.setBackground(Color.WHITE);Ok, well that looks perfectly sensible to me, however the scrollbar doesn't diplay with a balck foreground and a white background - it seems to just completely ignore those two lines of code! What on earth is going on? The documentation (http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Component.html#setForeground(java.awt.Color)) just says " Sets the foreground color of this component". Well, yeah, I figured that it might just do that, but it doesn't seem to!
TIA,
Mike.

Judging by the extent of the documentation, the designers don't say anything about what they consider "foreground" to be! I assumed it was the two little arrow bits and the twiddly bit in the middle of the scrollbar, with the background being everything else in the scrollbar. Perhaps it isn't so.
Phrased another way, my question is, "how do I change the color of the arrows and twiddly bit in the scrollbar, and how do I change the color of the rest of the scrollbar?". I am not fond of the drab grey ...
Thanks,
Mike.

Similar Messages

  • Can I set Mail default text color

    Is there a way to set default text color for sent messages?  These settings don't seem to have any effect:

    Only way I know how is to save a Draft with some character, even a space with color set & use that to Draft send.
    Or maybe set a Favorite in CMD+t in Mail.

  • How can I set the foreground/background color after using CSPickColor()?

    Hello all,
    Is there any one who has experience on changing foreground or background color using Photoshop Plug-in SDK?
    Currently I can get a returned color from CSPickColor(), but have no idea how to use it.
    Thanks!

    You can try a linear-gradient that starts at gray 0% and ends at white <whatever the percentage the thumb is at>.
            final Node track = slider.lookup(".track");
            slider.valueProperty().addListener(new ChangeListener<Number>() {
                public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
                    double pct = (t1.doubleValue()-slider.getMin())/(slider.getMax()-slider.getMin())*100;
                    track.setStyle("-fx-background-color: linear-gradient(to right, gray, gray " + pct + "%, white" + pct + "%, white);");
            });Edited by: dgrieve on Apr 12, 2012 12:19 PM

  • How can I create an alt background color for items in a jlistbox or jtree

    What I'm looking to do is have a white background for say items 1,3,5, etc. and a light yellow background for items 2,4,6, etc. I was wondering how can I set an alternative background color on items in a JTree or a JList

    Use a cell renderer:
    import java.awt.*;
    import javax.swing.*;
    public class ListAlternating extends JFrame
         public ListAlternating()
              String[] items = {"one", "two", "three", "four", "five", "six", "seven"};
              JList list = new JList( items );
              list.setVisibleRowCount(5);
              list.setCellRenderer( new MyCellRenderer() );
              JScrollPane scrollPane = new JScrollPane( list );
              getContentPane().add( scrollPane );
         public static void main(String[] args)
              ListAlternating frame = new ListAlternating();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setLocationRelativeTo( null );
              frame.setVisible( true );
         class MyCellRenderer extends DefaultListCellRenderer
              public Component getListCellRendererComponent(
                   JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
                   super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                   if (!isSelected)
                        setBackground(index % 2 == 0 ? list.getBackground() : Color.LIGHT_GRAY);
                   return this;
    }

  • Can't set up irssi colors

    I'm feeling really... stupid. I just can't set up irssi colors, almost ashame for asking advice on this
    Here's my theme (just cloned the default theme):
    # When testing changes, the easiest way to reload the theme is with /RELOAD.
    # This reloads the configuration file too, so if you did any changes remember
    # to /SAVE it first. Remember also that /SAVE overwrites the theme file with
    # old data so keep backups :)
    # TEMPLATES:
    # The real text formats that irssi uses are the ones you can find with
    # /FORMAT command. Back in the old days all the colors and texts were mixed
    # up in those formats, and it was really hard to change the colors since you
    # might have had to change them in tens of different places. So, then came
    # this templating system.
    # Now the /FORMATs don't have any colors in them, and they also have very
    # little other styling. Most of the stuff you need to change is in this
    # theme file. If you can't change something here, you can always go back
    # to change the /FORMATs directly, they're also saved in these .theme files.
    # So .. the templates. They're those {blahblah} parts you see all over the
    # /FORMATs and here. Their usage is simply {name parameter1 parameter2}.
    # When irssi sees this kind of text, it goes to find "name" from abstracts
    # block below and sets "parameter1" into $0 and "parameter2" into $1 (you
    # can have more parameters of course). Templates can have subtemplates.
    # Here's a small example:
    # /FORMAT format hello {colorify {underline world}}
    # abstracts = { colorify = "%G$0-%n"; underline = "%U$0-%U"; }
    # When irssi expands the templates in "format", the final string would be:
    # hello %G%Uworld%U%n
    # ie. underlined bright green "world" text.
    # and why "$0-", why not "$0"? $0 would only mean the first parameter,
    # $0- means all the parameters. With {underline hello world} you'd really
    # want to underline both of the words, not just the hello (and world would
    # actually be removed entirely).
    # COLORS:
    # You can find definitions for the color format codes in docs/formats.txt.
    # There's one difference here though. %n format. Normally it means the
    # default color of the terminal (white mostly), but here it means the
    # "reset color back to the one it was in higher template". For example
    # if there was /FORMAT test %g{foo}bar, and foo = "%Y$0%n", irssi would
    # print yellow "foo" (as set with %Y) but "bar" would be green, which was
    # set at the beginning before the {foo} template. If there wasn't the %g
    # at start, the normal behaviour of %n would occur. If you _really_ want
    # to use the terminal's default color, use %N.
    # default foreground color (%N) - -1 is the "default terminal color"
    default_color = "-1";
    # print timestamp/servertag at the end of line, not at beginning
    info_eol = "false";
    # these characters are automatically replaced with specified color
    # (dark grey by default)
    replaces = { "[]=" = "%K$*%n"; };
    abstracts = {
    ## generic
    # text to insert at the beginning of each non-message line
    line_start = "%B-%n!%B-%n ";
    # timestamp styling, nothing by default
    timestamp = "%K$*%n";
    # any kind of text that needs hilighting, default is to bold
    hilight = "%_$*%_";
    # any kind of error message, default is bright red
    error = "%R$*%n";
    # channel name is printed
    channel = "%_$*%_";
    # nick is printed
    nick = "%_$*%_";
    # nick host is printed
    nickhost = "[$*]";
    # server name is printed
    server = "%_$*%_";
    # some kind of comment is printed
    comment = "[$*]";
    # reason for something is printed (part, quit, kick, ..)
    reason = "{comment $*}";
    # mode change is printed ([+o nick])
    mode = "{comment $*}";
    ## channel specific messages
    # highlighted nick/host is printed (joins)
    channick_hilight = "%C$*%n";
    chanhost_hilight = "{nickhost %c$*%n}";
    # nick/host is printed (parts, quits, etc.)
    channick = "%c$*%n";
    chanhost = "{nickhost $*}";
    # highlighted channel name is printed
    channelhilight = "%c$*%n";
    # ban/ban exception/invite list mask is printed
    ban = "%c$*%n";
    ## messages
    # the basic styling of how to print message, $0 = nick mode, $1 = nick
    msgnick = "%K<%y$0%n$1-%K>%n %|";
    # message from you is printed. "msgownnick" specifies the styling of the
    # nick ($0 part in msgnick) and "ownmsgnick" specifies the styling of the
    # whole line.
    # Example1: You want the message text to be green:
    # ownmsgnick = "{msgnick $0 $1-}%g";
    # Example2.1: You want < and > chars to be yellow:
    # ownmsgnick = "%Y{msgnick $0 $1-%Y}%n";
    # (you'll also have to remove <> from replaces list above)
    # Example2.2: But you still want to keep <> grey for other messages:
    # pubmsgnick = "%K{msgnick $0 $1-%K}%n";
    # pubmsgmenick = "%K{msgnick $0 $1-%K}%n";
    # pubmsghinick = "%K{msgnick $1 $0$2-%n%K}%n";
    # ownprivmsgnick = "%K{msgnick $*%K}%n";
    # privmsgnick = "%K{msgnick %R$*%K}%n";
    # $0 = nick mode, $1 = nick
    ownmsgnick = "{msgnick $0 $1-}";
    ownnick = "%_$*%n";
    # public message in channel, $0 = nick mode, $1 = nick
    pubmsgnick = "{msgnick $0 $1-}";
    pubnick = "%N$*%n";
    # public message in channel meant for me, $0 = nick mode, $1 = nick
    pubmsgmenick = "{msgnick $0 $1-}";
    menick = "%Y$*%n";
    # public highlighted message in channel
    # $0 = highlight color, $1 = nick mode, $2 = nick
    pubmsghinick = "{msgnick $1 $0$2-%n}";
    # channel name is printed with message
    msgchannel = "%K:%c$*%n";
    # private message, $0 = nick, $1 = host
    privmsg = "[%R$0%K(%r$1-%K)%n] ";
    # private message from you, $0 = "msg", $1 = target nick
    ownprivmsg = "[%r$0%K(%R$1-%K)%n] ";
    # own private message in query
    ownprivmsgnick = "{msgnick $*}";
    ownprivnick = "%_$*%n";
    # private message in query
    privmsgnick = "{msgnick %R$*%n}";
    ## Actions (/ME stuff)
    # used internally by this theme
    action_core = "%_ * $*%n";
    # generic one that's used by most actions
    action = "{action_core $*} ";
    # own action, both private/public
    ownaction = "{action $*}";
    # own action with target, both private/public
    ownaction_target = "{action_core $0}%K:%c$1%n ";
    # private action sent by others
    pvtaction = "%_ (*) $*%n ";
    pvtaction_query = "{action $*}";
    # public action sent by others
    pubaction = "{action $*}";
    ## other IRC events
    # whois
    whois = "%# $[8]0 : $1-";
    # notices
    ownnotice = "[%r$0%K(%R$1-%K)]%n ";
    notice = "%K-%M$*%K-%n ";
    pubnotice_channel = "%K:%m$*";
    pvtnotice_host = "%K(%m$*%K)";
    servernotice = "%g!$*%n ";
    # CTCPs
    ownctcp = "[%r$0%K(%R$1-%K)] ";
    ctcp = "%g$*%n";
    # wallops
    wallop = "%_$*%n: ";
    wallop_nick = "%n$*";
    wallop_action = "%_ * $*%n ";
    # netsplits
    netsplit = "%R$*%n";
    netjoin = "%C$*%n";
    # /names list
    names_prefix = "";
    names_nick = "[%_$0%_$1-] ";
    names_nick_op = "{names_nick $*}";
    names_nick_halfop = "{names_nick $*}";
    names_nick_voice = "{names_nick $*}";
    names_users = "[%g$*%n]";
    names_channel = "%G$*%n";
    # DCC
    dcc = "%g$*%n";
    dccfile = "%_$*%_";
    # DCC chat, own msg/action
    dccownmsg = "[%r$0%K($1-%K)%n] ";
    dccownnick = "%R$*%n";
    dccownquerynick = "%_$*%n";
    dccownaction = "{action $*}";
    dccownaction_target = "{action_core $0}%K:%c$1%n ";
    # DCC chat, others
    dccmsg = "[%G$1-%K(%g$0%K)%n] ";
    dccquerynick = "%G$*%n";
    dccaction = "%_ (*dcc*) $*%n %|";
    ## statusbar
    # default background for all statusbars. You can also give
    # the default foreground color for statusbar items.
    sb_background = "%4%w";
    # default backround for "default" statusbar group
    #sb_default_bg = "%4";
    # background for prompt / input line
    sb_prompt_bg = "%n";
    # background for info statusbar
    sb_info_bg = "%8";
    # background for topicbar (same default)
    #sb_topic_bg = "%4";
    # text at the beginning of statusbars. sb-item already puts
    # space there,so we don't use anything by default.
    sbstart = "";
    # text at the end of statusbars. Use space so that it's never
    # used for anything.
    sbend = " ";
    topicsbstart = "{sbstart $*}";
    topicsbend = "{sbend $*}";
    prompt = "[$*] ";
    sb = " %c[%n$*%c]%n";
    sbmode = "(%c+%n$*)";
    sbaway = " (%GzZzZ%n)";
    sbservertag = ":$0 (change with ^X)";
    sbnickmode = "$0";
    # activity in statusbar
    # ',' separator
    sb_act_sep = "%c$*";
    # normal text
    sb_act_text = "%c$*";
    # public message
    sb_act_msg = "%W$*";
    # hilight
    sb_act_hilight = "%M$*";
    # hilight with specified color, $0 = color, $1 = text
    sb_act_hilight_color = "$0$1-%n";
    It's almost the way I want it, but a couple of things:
    - I want everyone nickname but mine in gray
    - I want the join/quit text (... has joined/quit) in gray
    - I want the mode (@, +, etc) in yellow
    I tried to format the text according irssi site, but without luck.
    For example tried this to change others nickname color:
    pubmsgnick = "{msgnick %y$0%n %K$1%n-}";
    pubnick = "%K$*%n";
    and this for the quit msg
    # mode change is printed ([+o nick])
    mode = "{comment %K$*%n}";
    # nick/host is printed (parts, quits, etc.)
    channick = "%c$*%n";
    chanhost = "{nickhost %c$*%n}";
    all without any luck. Also tried to put the format strings outside the curly braces, with the same result. I've been editing the config file for a while now, not sure what other information could you possibly need.
    I know it's not a big deal, I stil can use the program with no hassle, but it would really be nice to set the colors like that, to help me distinguish between lines.
    Thank you for reading, and sorry for my lousy english

    Nobody can tell you anything without proper system info or other technical details.
    Mylenium

  • How can i set the alternating colors for a table rows

    Dear All,
    Please any one help me how can i set the Alternating colors for Table Rows.
    i created a theam there i set the background alternating color to brown and i set the table design properity to alternating. but it is not reflecting.

    Hi,
    The design property in Table properties should work for your requirement. Select "alternating" value for design.
    Please see the API below:
    design
    Determines the appearance of the table. The property design can take the following values and is represented by enumeration type WDTableDesign.
    alternating - The table rows are displayed alternately in a different color.
    standard - The table background has one color. The individual table rows are displayed with grid net lines.
    transparent - The table background is transparent. The individual table rows are displayed without grid net lines.
    Check whether you have changed the right property or not? Also table should contain more than one rows to test this scenario.
    Regards,
    Jaya.
    Edited by: VJR on Jun 17, 2009 6:43 PM

  • How can  i set a image dinamically in a image component (ADF Mobile)?

    Hello everybody,
    I have to consume a rest service and get a url. This url is redirected to one image. After reading this image, how can i set he in a adf mobile image component?

    Hi,
    bind the mobile image component URL to a managed bean and have the managed bean. Then use the bean setter to set a new URL string and ensure (when creating the Java class for the managed bean) you have JDeveloper creating the property change event handlers.
    Frank

  • Can't set background color of boolean

    I'm trying my hand at a custom control.  It's a simple boolean 'arrow' indicator.  I started by placing a classic "flat square button", then imported the 'false' and 'true' versions of the arrow, which correspond to red and green.
    However, I want a 3rd state (off).  To accomplish this, I tried to use a property node, but it doesn't seem to work.  I created  a simple VI to test with, I've pasted the image below...I know the event structure is being executed, because I tested that by changing the boolean text inside the event structure.  To prove it can be done, I set every value of the array to blue, just to make sure I wasn't missing something about the true/false/t->f/f->t arrangement of the array.
    But all to no avail...I can click on the control and it changes from red to green, like I originally defined in the control.  Why can't I programatically change the color?  thanks in advance

    bmishoe wrote:But all to no avail...I can click on the control and it changes from red to green, like I originally defined in the control.  Why can't I programatically change the color?
    It is probably more likely that your imported pictures are just covering the background of the button.
    A picture ring is the better way to go anyways.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Can I set the text color in a Label?

    Hi everyone ~
    Can I set the font color in PP? I only found that there is a "setBackground".. but I want to set the color within a Label.
    Thanks!
    Gary

    Fixed it!
    There was a global style for s|Label and since the Spark button uses one of these for the text, that was it.

  • Datagrid: Can I set a tranparency level for column background color?

    Hi all,
    I have a datagrid with background colors set using triggers. This works. I would like to set a column background color but I don't want to make the color solid because it will block the row color. Is there a way to set the column background color transparency
    to 50% (or less) so that I can still see (or blend) with the row background color? I can set the "background" property of the column to a value of "transparent" but this makes no sense without a color.
    Thanks
    <DataGrid.RowStyle>
    <Style TargetType="DataGridRow">
    <Style.Triggers>
    <DataTrigger Binding="{Binding col_oPutorCall}" Value="call">
    <Setter Property="Background" Value="Cornsilk"/>
    </DataTrigger>
    <DataTrigger Binding="{Binding col_oPutorCall}" Value="put">
    <Setter Property="Background" Value="BlanchedAlmond"/>
    </DataTrigger>
    <DataTrigger Binding="{Binding col_rowColor}" Value="false">
    <Setter Property="Background" Value="LightGreen"/>
    </DataTrigger>
    </Style.Triggers>
    </Style>
    </DataGrid.RowStyle>
    <DataGridTextColumn Binding="{Binding col_oBid, StringFormat=F2}" FontFamily="Arial" FontWeight="Bold" FontSize="12" Header="oB" >
    <DataGridTextColumn.CellStyle>
    <Style TargetType="DataGridCell">
    <Setter Property="Background" Value= "Transparent" />
    <Setter Property="Background" Value= "AliceBlue" />
    </Style>
    </DataGridTextColumn.CellStyle>
    </DataGridTextColumn>

    Background is a brush.
    You can define a brush with an opacity in a resourcedictionary merged in app.xaml or in your window.resources ( etc ).
    <Grid.Resources>
    <SolidColorBrush x:Key="TransparentIshBrush" Color="Red" Opacity=".3" />
    </Grid.Resources>
    I should think you can then do:
    <DataGridTextColumn Binding="{Binding col_oBid, StringFormat=F2}" FontFamily="Arial" FontWeight="Bold" FontSize="12" Header="oB" >
    <DataGridTextColumn.CellStyle>
    <Style TargetType="DataGridCell">
    <Setter Property="Background" Value="{StaticResource TransparentIshBrush}" />
    </Style>
    </DataGridTextColumn.CellStyle>
    </DataGridTextColumn>
    The problem with your former piece of code is that setting an opacity on a datagridcell gets everything in it. You would have to do
    <Setter Property="(BackGround.Opacity)"
    And I'm rather doubtful that would work anyhow.
    Please don't forget to upvote posts which you like and mark those which answer your question.
    My latest Technet article - Dynamic XAML

  • How can I set the field ICt in component table of the Tasklist as "Input" ?

    Hi experts,
    How can I set the field ICt (BOM's Item Category (POSTP)) in component table of the Tasklist as "Input" Status (The system is in gray now).
    I can define the different Category value by IB01 or IB02,then I can select them at the Tasklist's component table.But sometimes I need batch input such as LSMW,so pls kindly tell me how to setup it,thanks!
    Yinjun

    Hi,
    BOM is created with some component and item category.
    In task list when you go to component, in normal case one selects and copies BOM over there by clicking component selection button.
    Once BOM is copied over there the BOM item category will get copied. As it is BOM item category in Task list it is greyed and it will get copied automatically from BOM.
    You specify item category required by you in IB01 or IB02 and then use that BOM in task list. Go to componenet tab and click component selection button. Once BOM is copied over there the BOM item category will get copied

  • How can I set the default print settings of my document as color.  I want the default print setting to be color when someone opens a document.  similar to duplex print preset is there a color print preset?

    How can I set the default print settings of my document as color.  I want the default print setting to be color when someone opens a document.  similar to duplex print preset is there a color print preset?

    Hi,
    Try saving your settings as a Preset by clicking the Preset drop down and then select Save Current Settings as a Preset.
    Next try changing the settings by selecting the saved preset.
    That allow saving the settings for a specific printer, I assume it may also allow selecting these settings for another printer.

  • How can i set background color of child window in jdk 1.6

    Hi friends i hv devoloped simple java app using javax.swing.JFrame in which on click button event i open new child window using JFrame to draw some image.
    i set childs background color as setBackground(Color.lightGray);
    but the problem is,child window takse its background color same as its parent window.(i.e. main window's color or desktop ).i get this problem in jdk 1.6.but it is working fine in jdk 1.5.
    how can i set background color of child window in jdk 1.6 .
    plz solve my problem.
    thanks in advanced.

    Mo,
    Call me old fassioned, but I simply refuse to demangle SMS speak.
    You've got a whole keyboard, so learn how to use it.
    Keith.

  • Hi Edge community,  How can I set a custom colors

    Hi Edge community,
    How can I set a custom colors & font size
    to the Adobe Edge Animate CC 2014
    work space (stage, time lone, tools, etc...)
    to get something close to this?
    http://www.vrmall.eu/vr/EDGE_WORKSPACE_BLACK_n_WHITE/EDGE_WORKSPACE_BLACK_n_WHITE_r.01.jpg
    Thanks a lot for Your time and help.

    Hi Robyn_cpl,
    thanks for the useful link - based on this I decided to
    purchase the PDF of Adobe Edge Animate: The Missing Manual
    by Chris Grover. Good book indeed, work space panels resizing
    and docking are covered, but there is nothing on colors&fonts...
    I've been searching  intro's, tut's, forums on Edge, but no hint
    on this... But I keep searching You Tube, Google, etc...
    I'm intended to submit the subject to Adobe Edge Support.
    Thanks again for Your attention

  • HELP !!! How can I set the size of each component separately

    Please tell me, when adding components (a mix of
    labels , buttons etc.) on a container (swing), how can I set the size
    of each component separately.
    for example:
    the code here has a mix of button and a grid that is actually another JPanel. Its a part of a bigger
    program. When running the grid is cut (not seen in its full size).
    So, please try to anser also about the specific acse of frame contining another frame in it , and the interior should be right sized.
    The relevant part of the code:
    =========================================
    public class Reversi extends JFrame {
    public static void main(String[] args) {
    Reversi ourGame = new Reversi();
    public Reversi() {
    super("Grid Reversi");
    setSize(new Dimension(300, 300));
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    Grid g = new Grid(); // the grid was built at another part..
    ReversiGame ourGame = new ReversiGame();
    JButton b;
    JFrame f = new JFrame("Hello Java");
    f.setSize(new Dimension(300, 300));
    f.setDefaultCloseOperation(EXIT_ON_CLOSE);
    Container c = f.getContentPane();
    c.add(g,BorderLayout.NORTH );
    c.add(b = new JButton("Hola"), BorderLayout.CENTER);
    //f.pack();
    f.show();

    BorderLayout chooses the sizes of each of the components added to it. Choose a different layout manager (or set the placement/size manually with a 'null' layout)
    http://java.sun.com/developer/onlineTraining/GUI/AWTLayoutMgr/shortcourse.html

Maybe you are looking for

  • New mac mini, resolution incompatible with TV

    My shiny new mac mini just arrived today in the mail. I hooked it up to my Emerson 27 inch 720p tv and booted her up. I got the grey screen, then the apple, then a spinny wheel of white lights, then "Please change computers resolution". This is my fi

  • Netflix "Slo-Mo" with 2011 Mini Server and Yosemite

    I have recently run into a problem with my 2011 Mini Server and Yosemite. Now that I am using my Mini as a HTPC with Yosemite, when I first boot and then log into Netflix and start a movie or TV show, the playback runs in literally slow motion.  Vide

  • Clarification req

    Hi all, When am copying my query (rszc and save as ) Original file is populating the data for the Objects( res KF's) as per req. but for the copied one(duplicate) data is not populating, it just showing all zeros for key figures(Restrcited). can any

  • Placing Images - Scale to Fill, to Fit, etc.

    When I place an image in a Muse composition and use the program's scaling functions, what happens to the image quality? For example, if I'm building a slide show and I have Photoshop images that are 1500 pixels wide @ 72 dpi, but my slide show is onl

  • Read the version of deployed EAR modules via JMX (WLS 10.0)

    Hello We are deploying some EAR components into a WLS 10.0. Now we want to monitor the version number of the deployed EARs via a JMX client. The version number is provided in the manifest of the EAR (Implementation-Version). I read through some JMX r