How to set the color of ticks in JSlider

Hi,
Question about JSlider.
I am trying to set various colors between the ticks. However, I have gone thro' the javadoc of JSlider but find no such API.
How could I go this?
Thanks in advance for any inputs and ideas.
Wing

Here is quick demo about customize thumb.
It is similar for customize other part of JSlider.
You can use setUI to force use your own UI.
Create your UI, the better way is extend from existing UI,
for example: BasicSliderUI or MetalSliderUI (or... depend on L&F you want).
Check the BasicSliderUI and MetalSliderUI API
customize the paintXXXX method, that's it.
Good Luck.
import javax.swing.*;
import java.awt.*;
import javax.swing.plaf.metal.MetalSliderUI;
public class Test {
  public static void main(String[] args) {
    JFrame f = new JFrame();
    JSlider slider = new JSlider();
    slider.setPaintTicks(false);
    slider.setUI ( new MetalSliderUI() {
      public void paintThumb(Graphics g)  {
          Rectangle knobBounds = thumbRect;
          Color color = g.getColor();
          g.setColor(Color.red);
          g.fillOval(knobBounds.x, knobBounds.y, 15,15);
          g.setColor(color);
    f.getContentPane().add (slider);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.pack();
    f.setVisible(true);
}

Similar Messages

  • Can u tell me how to set the color of the button and its border

    hi to all,can u tell me how to set the color of the button and its border

    There are sample code on the java.sun.com
    http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/index.html
    try this web page ... There are lots of examples... Good luck ... "Gan en "

  • How to set the color to the particular row in a report

    Hi
    I have a report in which I have an edit link(I changed the id as edit link)..When I click that link, all the details(the whole row details) will be appearing on the items nearer to the report to save the changes....
    I want to set the color for the particular row when a link is clicked and the color should not be changed until I save the changes in items...After saving the changes, the report should come in the normal color...this is my requirement..i refered many forums regarding this...But could not find solution....If anyone knows,please help me...
    Fazila

    Here is how I would implement
    Create renderer
    Add SkinnableContainer element and create a skin for this container namely SkinnableContainerSkin
    find the fill section in the skin
    add bitmap fill to the fill section and give the source of the image which you are planning to use(Hopefully this is a direct way of doing, may be you need to hack this a little to get it to work)
    I've never tried this, but should help you give some idea.

  • How to set the color scale so that we can get same color for same intensity of color in various runs

    Hi
    I am trying to get the color pattern of mashed potato trays and diferent trays has different color intensity but if IF i am chsooing rainbow plateu it's giveing red color for dark region of each tray but two tray has different intensity of dark color. Can you suugest me how should I set the color scale so that I can distinguish which tray has higher degree of intensity of darkness.
    I will be obliged to get the suggestions

    Hello,
    Thank you for contacting National Instruments. I just have a few questions for you to help us clarify your application:
    What API, such as LabVIEW or C, are you programming your application in?
    Are you using Vision, and if so what specific functions are you currently using?
    Is the lighting consistent and just the color of the trays changing?
    How are you displaying the image in your program? Are you using an Image Display control?/li>
    Depending on what functions you have available, then we may be able to work on finding a way to distinguish between the different intensities. If you could provide a little information to your application based on these questions then will be able to better understand and help you with your app
    lication.
    Regards,
    Michael
    Applications Engineer
    National Instruments

  • How to set the color for road map steps

    hi all,
    my requirement is like ,whenever i select my step in a roadmap it has to be set in yellow color and others has to be in default color.
    thanks,
    Siva.

    Hi......
    Its Very Simple......
    Create an action for the road map.
    for example..... if you have three step in it....
    by default the first step will be in active only...
    ie., Yellow colour
    if you click the second step and it should be active means.... if you have to create a event....in the property of the Roadmap
    Create the on action select event....
    in that event.....
    try to use this code.... based on your scenario.....
    set context data
        DATA: road_node TYPE REF TO if_wd_context_node,
              road_data TYPE if_componentcontroller=>element_roadmap.
        road_node = wd_context->get_child_node( 'ROADMAP' ).
        road_data-step = step.
        IF step = 'CHOOSE'.
          road_data-prev_enabled = abap_false.
        ELSE.
          road_data-prev_enabled = abap_true.
        ENDIF.
        IF step = 'END'.
          road_data-next_enabled = abap_false.
        ELSE.
          road_data-next_enabled = abap_true.
        ENDIF.
        road_node->set_static_attributes( road_data ).
    navigation
        wd_this->fire_navigate_evt( step ).
    Hope this will help you
    Thanks & reagrds
    Raja

  • Setting the color on selected Tab

    Hi,
    I can't seem to figure out how to set the color on the
    selected tab in a JTabbedPane. I've added a
    ChangeListener but when I try to use it, it only
    changes the color after the tab has been selected.
    I want to change it while it is selected.
    How can I do this?

    Maybe this helps:
    http://www2.gol.com/users/tame/swing/examples/SwingExamples.html
    Kurta

  • How 2 set the background color in j2me

    Can any body tell me how to set the background color to midlet.??

    if you are using Screen then you can call its setBackColor()
    or if you are using Canvas then you can call
    g.setColor(r,g,b);
    g.fillRect(0,0,getWidth,getHieght);
    where g is the Graphics instance of Canvas,for further information consult documentation

  • How to set the 4th Y axis color for a line graph

    Hello experts,
    I have developed a multiple y axis line graph using oracle reports 10g.
    It has got 1 x axis and 4 axes. I am able to set the color of the the first three y axes
    but the reports designer automatically assigns yellow color to the 4th axis.
    I mean there is no option in the graph wizard for changing the 4th color)
    How to change the color of this 4th y axis to a desired color?
    Cheers
    Sri

    Assuming you mean that your graph has 4 series, not 4 Y axes, you might try something like this:
    1. Save a backup copy of your current report in case the changes you are about to make don't work out and you want to revert to the backup copy.
    2. Using the Property Inspector, display the current value of the Graph Settings property for your graph. The value of the property should be something like:
    <rw:graph id...
    </rw:graph>3. Look for a <SeriesItems> tag and a matching </SeriesItems> tag in the property value. If you don't find them, add the following two lines immediately before the </Graph> tag.
    <SeriesItems>
    </SeriesItems>4. Between the <SeriesItems> tag and the matching </SeriesItems> tag, add (or update) a <Series> tag for each series that you want to specify the color for. For example, to specify the color of the fourth series as red, you would use a <Series> tag like this:
    <Series id="3" color="#ff0000"/>Note that the id numbers start at 0 for the first series, 1 for the second, and so on. The color value is a hexadecimal number specifying the RGB value of the color.
    You can also use the <Series> tag to specify other features like the marker shape.
    For more information on what you can do using the Graph Settings property, see this FAQ and Technical Note.
    Hope this helps.

  • Link Color not changing for Visited Pages - How do I set the Color?

    In earlier versions of Safari, the user could select the color used to display links that have already been visited. I can't find that option in Preferences anymore. Some visited links do show a different color, some don't. Is it just random? How do I set the color in Safari 4.0.4 and activate the behavior?

    HI,
    I think you change visited pages link colors using Google preferences.
    http://www.googleguide.com/preferences.html
    Carolyn

  • How to set the (specific) color for a Chart Series in a Flash Diagramm

    Hello all,
    I wonder how I can set the color (of a bar) for a Chart Series in a Flash Diagramm.
    So far I found now set-screw for this.
    Can someone give me a hint please.
    Thanks in advance.
    Andre

    Hi,
    On the Chart Attributes page for the region, change the "Color Scheme" setting to Custom. Then, in the "Custom Colors" setting, enter the colours you want for all series, separated by a comma. For example:
    red,yellow,greenAndy

  • How can I set the color for a textfield

    Hi all,
    I use a textfield and I want to set the color for characters which are typed in the textfield. I didn't find anywhere a solution for this. Do you know how I should implement this?
    Thanks

    Not possible. If you want this, you'll need to make a custonItem that implements this.

  • How to set the text color in a Canvas?

    When I use (Graphics) g.setColor(255,255,255), then g.drawString("xxx", 0, 0, ....);
    the simulator works well but it can't work in my mobile phone (Nokia 7650).
    What's wrong?
    Thanks.

    do it like this
    g.setColor(255,255,255);//this will set the color for the canvas
    g.fillRect(0,0,ht,wd);//this will fill the rect(screen) with the above color,actually this will be BG color for ur app..ht,wd are the height and width of ur canvas...
    now specify color for the text
    g.setColor(r,g,b);//this color shud ofcourse be diff frm the color set for BG
    now draw the string
    g.drawString("xxx", 0, 0, ....);

  • Q:How to set the inactive 'sub-tab' text color?

    On portal.oracle.com I created my own Page Style (changed the
    color scheme) from the default and then added 'sub-tabs' to the
    Group Docs tab. Now when you click on Group Docs you see four
    'sub-tabs' underneath it. The problem I am having is that on the
    inactive tabs the text is not what I set when I created the Page
    Style. It appears to be reverting to color of the original Style
    which was created for my Portal. Any suggestions?

    do it like this
    g.setColor(255,255,255);//this will set the color for the canvas
    g.fillRect(0,0,ht,wd);//this will fill the rect(screen) with the above color,actually this will be BG color for ur app..ht,wd are the height and width of ur canvas...
    now specify color for the text
    g.setColor(r,g,b);//this color shud ofcourse be diff frm the color set for BG
    now draw the string
    g.drawString("xxx", 0, 0, ....);

  • How to set the default component color

    Hi
    I have a JFormattedTextField which is part of a form. Based on user input, if there's something wrong in it, then I colour it pink. I also make it editable(true) or editable(false) based on the mode that I am.
    Problem I have is that once I set the color of it once (to pink), then it won't change the colour of the Textfield based on mode when I call setEditable(true/false) anymore. I want it to "unset" the colour that I did and not have to colour it everytime. I don't want to have to manually change the colour after I set the colour once.
    Can anyone help me with this?
    Thanks!

    Thanks camickr !
    That's exactly what I was looking for. (let the UIManager take care of colors of the textfield whether it's editable or not)
    as for 2nd reply my code is in several files. IF i have to shorten it, it would be:
    it's just a pseudo code and incomplete but it gets the idea across
    * this function automatically changes colors of textfield based on mode which can change any time
    if(mode == NEW_MODE)
    textField.setEditable(true);
    else
    textField.setEditable(false);
    * This function sets the color during save time
    public void save()
    clear();
    if(textField.getText() == null)
    textField.setBackGround(Color.PINK);
    public void clear()
    //reset the color if it's pink or to the original color
    //the color must update once we change mode which is independent of this
    public void open(Patient p)
           clear();
           displayPatient(p);
    }

  • How to set the default Color Picker?

    Hello everyone,
    I wrote my own Color Picker and it works nicely within the standard apple color picker panel. I am quite annoyed, however, that I have to switch to my new Color Picker by hand every time I open the Color Picker Panel. I have found that I can set an application-speficic default color picker by setting the NSColorPickerSlidersDefaults property for that application using defaults. However, that way I can only set one of the original apple color pickers to be the default, not my own, because there is no number defined for my own color picker and I can't add it.
    Does anyone know a solution please?

    Thanks camickr !
    That's exactly what I was looking for. (let the UIManager take care of colors of the textfield whether it's editable or not)
    as for 2nd reply my code is in several files. IF i have to shorten it, it would be:
    it's just a pseudo code and incomplete but it gets the idea across
    * this function automatically changes colors of textfield based on mode which can change any time
    if(mode == NEW_MODE)
    textField.setEditable(true);
    else
    textField.setEditable(false);
    * This function sets the color during save time
    public void save()
    clear();
    if(textField.getText() == null)
    textField.setBackGround(Color.PINK);
    public void clear()
    //reset the color if it's pink or to the original color
    //the color must update once we change mode which is independent of this
    public void open(Patient p)
           clear();
           displayPatient(p);
    }

Maybe you are looking for

  • Problem with drivers for HP B109 a-m all-in-one, have printer working but not scanner in windows 8

    Still have a problem with the drivers in Windows 8 release preview, for my HP B109 a-m all-in-one, have printer working but not scanner, is there any chance of a fix before final release of Windows 8 ?.

  • Issue certview exam history result

    Hi i got an issue to view my score report in certview... Issue is i had taken my 1Z0-238 (Oracle EBS R12: Install, Patch and Maintain Oracle Applications) exam with personvue.. from a few days in cert view Exam History in Grade Indicator it says REVO

  • Modify itab not working

    Hi , I am trying to change a field value in itab using MODIFY statement. The field is a char type and holding '0000000' initially. Now I am trying to change this value to other value. But the modify statement is not working. like the code is, data :

  • Problems installing JDeveloper

    Hi all, I have recently installed JDeveloper from patch 6739235. I connected to vision instance of apps version 11.5.10.2 and tested it, it gave me success. When i built the tutorial.jpr, it builds with 25 warnings & 0 errors. And when i try to run t

  • HT201272 Problem with app from old phone to new phone

    I had to get a new iPhone 5 and downloaded my existing apps through iCloud. However, one of the apps from my old phone was upgraded and I paid a yearly subscription fee. When I received my new phone and downloaded this upgraded app, my new phone did