Setting Jslider background Image ?

Hi,
I am trying to use JSlider component with a background image, but I am not successfull. Can anyone suggest how to do that.
I am tried to subclass JSlider and override the paint method, but then i can see only the image but not the knob and slider rule on it.
I am also trying to get the knob pointing west instead of east in vertical orientation. Is there any way to do that too.
Any kind of info or input is highly appreciated
thanks
srinivas

Don't know if this will help much, but I'll post it anyway. :)
This is how I did an aqua slider. All images that I use, are taken and changed (a bit) from the aqua LAF from MacOS X.
The ImageLoader class is also a custom class that helps a bit to load Images.
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.border.*;
import javax.swing.plaf.basic.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.plaf.*;
import java.beans.*;
import javax.swing.plaf.metal.*;
public class ThemesSliderUI extends MetalSliderUI
  //public static final ThemesSliderUI sliderUI = new ThemesSliderUI ();  // creates a nice bug.. %-p
  protected static ImageIcon horiz_knob_enabled  = ImageLoader.loadImage ("aqua_slider_active_horizontal_knob");
  protected static ImageIcon horiz_knob_disabled = ImageLoader.loadImage ("aqua_slider_inactive_horizontal_knob");
  protected static ImageIcon vert_knob_enabled   = ImageLoader.loadImage ("aqua_slider_active_vertical_knob");
  protected static ImageIcon vert_knob_disabled  = ImageLoader.loadImage ("aqua_slider_inactive_vertical_knob");
  protected static ImageIcon hor_track_left_enabled    = ImageLoader.loadImage ("aqua_slider_track_active_horizontal_left");
  protected static ImageIcon hor_track_center_enabled  = ImageLoader.loadImage ("aqua_slider_track_active_horizontal_center");
  protected static ImageIcon hor_track_right_enabled   = ImageLoader.loadImage ("aqua_slider_track_active_horizontal_right");
  protected static ImageIcon hor_track_left_disabled   = ImageLoader.loadImage ("aqua_slider_track_inactive_horizontal_left");
  protected static ImageIcon hor_track_center_disabled = ImageLoader.loadImage ("aqua_slider_track_inactive_horizontal_center");
  protected static ImageIcon hor_track_right_disabled  = ImageLoader.loadImage ("aqua_slider_track_inactive_horizontal_right");
  protected static ImageIcon ver_track_left_enabled    = ImageLoader.loadImage ("aqua_slider_track_active_vertical_left");
  protected static ImageIcon ver_track_center_enabled  = ImageLoader.loadImage ("aqua_slider_track_active_vertical_center");
  protected static ImageIcon ver_track_right_enabled   = ImageLoader.loadImage ("aqua_slider_track_active_vertical_right");
  protected static ImageIcon ver_track_left_disabled   = ImageLoader.loadImage ("aqua_slider_track_inactive_vertical_left");
  protected static ImageIcon ver_track_center_disabled = ImageLoader.loadImage ("aqua_slider_track_inactive_vertical_center");
  protected static ImageIcon ver_track_right_disabled  = ImageLoader.loadImage ("aqua_slider_track_inactive_vertical_right");
  public static ComponentUI createUI (JComponent c)
    // Don't use the sliderUI variable from above, instead create each time a new instance!!!
    return new ThemesSliderUI ();
  public void installUI (JComponent c)
    if (UIManager.get ("Slider.trackWidth") == null)
      UIManager.put ("Slider.trackWidth", new Integer (7));       // default value from MetalLAF
    if (UIManager.get ("Slider.majorTickLength") == null)
      UIManager.put ("Slider.majorTickLength", new Integer (6));  // default value from MetalLAF
    super.installUI (c);
  public void update (Graphics g, JComponent c)
    if (c != null && c instanceof JSlider)
      JSlider sl = (JSlider)c;
      if (sl.isOpaque())
        sl.setOpaque(false);
      //g.clearRect (0, 0, sl.getSize().width, sl.getSize().height);
      if (sl.getOrientation() == JSlider.HORIZONTAL && horiz_knob_enabled != null && horiz_knob_disabled != null)
        horizThumbIcon = sl.isEnabled() && sl.hasFocus()? horiz_knob_enabled : horiz_knob_disabled;
      else if (sl.getOrientation() == JSlider.VERTICAL && vert_knob_enabled != null && vert_knob_disabled != null)
        vertThumbIcon = sl.isEnabled()  && sl.hasFocus()? vert_knob_enabled : vert_knob_disabled;
    paint (g, c);
    g.dispose();
  public void paintTrack (Graphics g)
    Rectangle r = trackRect;
    if (slider.getOrientation() == JSlider.HORIZONTAL)
      if (hor_track_left_enabled != null  && hor_track_center_enabled != null  && hor_track_right_enabled != null &&
          hor_track_left_disabled != null && hor_track_center_disabled != null && hor_track_right_disabled != null)
        g.translate (r.x, r.y+getThumbSize().height/3);
        g.drawImage ((slider.isEnabled()? hor_track_left_enabled : hor_track_left_disabled).getImage(), 0, 0, null);
        for (int x=hor_track_left_enabled.getIconWidth(); x<r.width-hor_track_right_enabled.getIconWidth(); x++)
          g.drawImage ((slider.isEnabled()? hor_track_center_enabled : hor_track_center_disabled).getImage(), x, 0, null);
        g.drawImage ((slider.isEnabled()? hor_track_right_enabled : hor_track_right_disabled).getImage(), r.width-hor_track_left_enabled.getIconWidth(), 0, null);
        g.translate (-r.x, -(r.y+getThumbSize().height/3));
        else super.paintTrack (g);
    else
      if (ver_track_left_enabled != null  && ver_track_center_enabled != null  && ver_track_right_enabled != null &&
          ver_track_left_disabled != null && ver_track_center_disabled != null && ver_track_right_disabled != null)
        g.translate (r.x+getThumbSize().width/3, r.y);
        g.drawImage ((slider.isEnabled()? ver_track_left_enabled : ver_track_left_disabled).getImage(), 0, 0, null);
        for (int x=ver_track_left_enabled.getIconHeight(); x<r.height-ver_track_right_enabled.getIconHeight(); x++)
          g.drawImage ((slider.isEnabled()? ver_track_center_enabled : ver_track_center_disabled).getImage(), 0, x, null);
        g.drawImage ((slider.isEnabled()? ver_track_right_enabled : ver_track_right_disabled).getImage(), 0, r.height-ver_track_left_enabled.getIconHeight(), null);
        g.translate (-r.x-getThumbSize().width/3, -r.y);
        else super.paintTrack (g);
    g.dispose();
  protected Dimension getThumbSize()
    Dimension size = new Dimension();
    if ( slider.getOrientation() == JSlider.VERTICAL )
      if (vert_knob_enabled != null)
        return new Dimension (vert_knob_enabled.getIconWidth(), vert_knob_enabled.getIconHeight());
      else  return super.getThumbSize();
    else
      if (horiz_knob_enabled != null)
        return new Dimension (horiz_knob_enabled.getIconWidth(), horiz_knob_enabled.getIconHeight());
      else  return super.getThumbSize ();
}

Similar Messages

  • How to set a background image to fill the entire screen on any device in a spark mobile application

    Hi,
    I started developing a mobile application with Flex.
    I'm trying to set a background image to fill the whole screen. I've been stucked at this point for days now. I tried everything and no solution seems to work for me.
    I'm using a TabbedViewNavigatorApplication and i need to set some background images on views.
    I need my image to fill the entire screen on any device. i don't need to mantain image aspect ratio,  just need it to be fullscreen. This seemed to work when setting a custom skin on the TabbedViewNavigatorApplication, however this blocked all my views for some reason and all components contained in view became invisible.
    Can you please tell me how can i achieve this?
    Kind regards,
    Dan

    Basically you need a larger image which can accommodate any device. The trick is to show only what each device can display, so therefore some clipping will occur based on device. Have something centered and towards margins have a  gradient or just plane colors that way the stuff in the middle will be visible on every device while nobody will care if you are clipping from the color fill.
    C

  • How to set a background image in Web dynpro for Java?

    Hi,
    Experts,
    As i  want to set a background image in my application can u please suggest how to get background image. send any sample scenarios.
    Thanks in advance,
    Shabeer ahmed

    Hi,
    I don't  think it can be done in WDJ.
    Maybe something can be done on the portal end.
    Refer to http://help.sap.com/saphelp_nw70/helpdata/en/79/affe402a5ff223e10000000a155106/frameset.htm
    Changing the theme can help maybe but I do not know how to go about that
    Regards,
    Himanshu

  • Set body background image in reflow

    Hi, I've been lookoing up and down to find where I can set a background image for a page in reflow. Cant find it anywhere. If I manually edit the html or css in the files edge generates to add a background image, of course it works, but next time I reopen the project in reflow, my changes get deleted, and I am back where I was before.
    So, where in reflow can I set the background image?
    thanks and best regards,
    c

    Something like this? Background Pictures Edge Reflow

  • Setting a background image using CSS Designer

    I am trying to set a background image for a page header using the CSS Designer. When I click the browse button the Select Image Source dialog box launches but any time I click on something the dialog box closes and no changes are made. Does anyone know what is causing this?

    Which DW are you using and which platform/OS, please? I am unable to reproduce this with CC2014 on OS10.9.4

  • Setting a background image on JApplet

    Hi all,
    I am new to swing programming. i have to develop a web enabled pgm. for the gui i need to set a background image. i saw some postings in this forum but they didn't satify my requirement. my main class extends from JApplet & it uses a borderLayout. in this i'm putting 2 panels. i need to set the background of the WEST region an image. i used
    getLayeredPane().add(label, new Integer(-1))
    to add the background image. but when i added the panel to the container then the panel is not getting displayed. i added like
    Container c = getContentPane().
    c.setLayout(new BorderLayout());
    c.add(panel,BorderLayout.NORTH);
    here label is a JLabel, panel is a JPanel.
    Can somebody help me with a solution. what i should be doing to get everything displayed.
    Thanks in advance

    check this post : http://forum.java.sun.com/thread.jsp?forum=57&thread=316074

  • Does ne1 now the html code to set a background image=non repeat, center for dreamweaver or where to find it?

    Im trying to set up an about me page like that of myspace.com
    i know that in myspace you can set the background image center non
    repeat can this be done as will with dreamweaver?

    Hello,
    Yes, it can be done using CSS.
    You can place this in your code, right before </head>.
    Just substitute your image for mypicture.jpg.
    <style type="text/css">
    <!--
    body {
    background-image: url(mypicture.jpg);
    background-repeat: no-repeat;
    background-position: center center;
    -->
    </style>
    -OR-
    You can also do this using DW's dialog boxes (like a wizard).
    If you have DW8 or CS3...or MX2004 if memory serves, you can
    right click on
    your page in design view.
    Select CSS Styles > New
    A CSS Rule dialog box opens.
    Select tag, then in the tag box, type body.
    You can select whether you want to add the CSS to this page
    (like the code
    above) or to a stylesheet linked to this page. If you are
    going to use CSS
    on multiple pages, it's a good idea to use a stylesheet. Then
    you can make
    changes in one place that affects all the pages linked to
    that stylesheet.
    When you click OK, a new box will open where you can define
    your CSS.
    Select "background" from the sidebar, and the fill in areas
    are pretty self
    explanatory.
    I hope that helps.
    Take care,
    Tim
    "Jimtheman2000" <[email protected]> wrote in
    message
    news:fo84t1$je9$[email protected]..
    > Im trying to set up an about me page like that of
    myspace.com i know that
    > in myspace you can set the background image center non
    repeat can this be
    > done as will with dreamweaver?

  • Why is there a scroll bar though I set the background image to "scale to page size"?"

    Why is there a scroll bar though I set the background image to "scale to page size"?"

    The current build of iTunes may occasionally draw the scroll bar off the edge of the screen. It should be possible to resize the window to reveal the scroll bar.
    You can restore much of the look & feel of the previous version with these shortcuts:
    Ctrl-B to turn on the menu bar.
    Ctrl-S to turn on the sidebar.
    Ctrl-/ to turn on the status bar.
    Click the magnifying glass top right and untick Search Entire Library to restore the previous search behaviour.
    You can also open the menu bar temporarily by pressing Alt.
    tt2

  • Setting a background image w/ Flash

    Hello -
    Is there a way to set up a background image (repeating or non-repeating) that the stage area floats over.
    When I use file > publish settings > HTML > publish - It creates the HTML document but any area outside the stage is colored with the default stage color- Can this be set up in Flash or changed in HTML ???
    Here is a section of the HTML document:
    <body bgcolor="#ff00ff">      <--- This is the current stage color in Flash
    <!--url's used in the movie-->
    <!--text used in the movie-->
    <!-- saved from url=(0013)about:internet -->
    <script language="JavaScript" type="text/javascript">
        AC_FL_RunContent(
            'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',
            'width', '100%',
            'height', '100%',
            'src', 'krae_pink',
            'quality', 'high',
            'pluginspage', 'http://www.adobe.com/go/getflashplayer',
            'align', 'middle',
            'play', 'true',
            'loop', 'true',
            'scale', 'noscale',
            'wmode', 'window',
            'devicefont', 'false',
            'id', 'krae_pink',
            'bgcolor', '#ff00ff',   <---- This is the current stage color in Flash
            'name', 'krae_pink',
            'menu', 'true',
            'allowFullScreen', 'false',
            'allowScriptAccess','sameDomain',
            'movie', 'krae_pink',
            'salign', ''
            ); //end AC code
    </script>
    Thanks- Ben L

    Yes you can but flash does not add background image for you. It only generates the HTML file with the object-embedding script. Then you will need to add the HTML script to add the background. Also you will need to set the SWF object as transparent so that it will "hover" over the HTML file. Do that by setting the wmode property of the embedding code which looks like this: http://www.pastie.org/822998. Or set the Window Mode under HTML tab of Publish settings to "Transparent Windowless".

  • How to set a background image in javafx?

    Hi everyone,
    I draw FXML GUI,it includes labels and ProgressBar,load it in JavaFX, this is a snippet.
    root = FXMLLoader.load(getClass().getResource("StartMenuFXML.fxml"));
    label1=(Label)root.lookup("#label");
    label2=(Label)root.lookup("#label");
    progressBar = (ProgressBar)root.lookup("#ProgressBar");
    scene=new Scene(root,600,400);
    stage.setTitle("Start Progress");
    Progress p = new Progress();
    p.start();
    stage.setScene(scene);
    stage.show();
    I need to add a background picture in it, so I add the statements:
    GridPane pane = new GridPane();
    pane.setTitle("-fx-background-image: url('image1.jpg')");
    and change: scene =new Scene(pane,600,400);
    It can display the background picture, but I don't know how to display the labels and ProgressBar on the background picture.
    Give me a good resolution please!
    Thank you so much!

    James_D,
    Your answer is the exact solution, you are a real expert.
    Thank you very very much!!!

  • Setting the background image in a JFrame

    Hi all,
    I have a .gif that I want to display as the background image in a JFrame. How do I do that?
    regards,
    Mat

    Check out this thread:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=288769

  • Can we set the Background Image for a Report

    Hi,
    I am generating a report thru the web now i want to give the background image to the report, let me know if any body knows about this.
    Thanx

    hello,
    try the before reports value of your report-level properties. add the BACKGROUND attribute to the BODY tag to reference an image-file for the background.
    regards,
    the oracle reports team

  • Set my background image with right click?

    Is there a way to set a picture as my desktop background without looking through tiny pictures in system prefs? I just want the right click feature. The only way this works is if you right click a picture ONLINE, but this doesnt work in my pictures folder...

    You can always drag a picture from your folder into Safari, then right click and select "Use Image as Desktop Picture"--might hit a snag though with some things in portrait orientation, they can display in landscape.
    Another option is make an Automator action, save it as a plug-in for Finder. You then right click, go to More, Automator, and select your action and get the new Desktop.
    Francine
    Francine
    Schwieder

  • How do you set a background image in Pages?

    I have a simple question. How do you set an image to be the background of a Pages '09 document? How do you put a JPG image behind your regular body text? Surely it's possible, but I can't figure out how to do it.

    You just didn't took care to the status of your picture.
    It was an inline one
    Change its status to floating and the menu item is no longer grayed.
    This kind of features are described in Pages User Guide which is also for you
    Yvan KOENIG (VALLAURIS, France) mercredi 13 juillet 2011 22:40:00
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8
    Please : Search for questions similar to your own before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • Setting A Background Image

    Hi wondered if anyone can help. I know you can set the stage
    background colour in flash and the published movie will sit central
    on top of the background. I want to set a pattern behind my
    published flash file. I dont want the scale of this pattern to
    change when the window is resized or moved by the user - i just
    want more of the pattern to appear (with my published flash file
    kind of floating ontop). Is there any way to do this.
    Thanks for any help
    Ad

    Hi wondered if anyone can help. I know you can set the stage
    background colour in flash and the published movie will sit central
    on top of the background. I want to set a pattern behind my
    published flash file. I dont want the scale of this pattern to
    change when the window is resized or moved by the user - i just
    want more of the pattern to appear (with my published flash file
    kind of floating ontop). Is there any way to do this.
    Thanks for any help
    Ad

Maybe you are looking for

  • Mail wont let me click 'send' button

    I have a problem and then some questions about my mail app. Below is a screenshot of my problems, the main problem is it wont let me click the 'send' button. The other problem is there is that triangly line symbol new to my windows live account and i

  • How to visualiza just particular lines in InfoView report

    Hi, I'd like to know how to visualize in InfoView report  that contatin following variables ="ID, TypeNUM, Value" just lines that have populate TypeNUM with the Maximium value for single ID like in the following example: Starting table ID     TypeNUM

  • Delete a Condition from item of particular sales order.

    I tried BAPI_SALESORDER_CHANGE and passed the following code. But instead of deleting it updates the condition even though update flag is kept to D.             move:     'x' to y_wa_condx-cond_type,                         y_wa_konv-kschl to y_wa_co

  • Level 0 exact fit, level 1 original size in browser?

    Hello everybody! im searching for a help if anyone can help will be apreciated. I use one movie that should fit the full browser window, as a background, I used ExactFit from html and was just fine, and one movie that should be the website content on

  • Thanks for help in transition to PC

    Thanks and a tip of the hat to Safe Harbor Computers, Caldigit, Nvidia , RGS,  Zaxwerks  & HP for their support in my PC transition.