Using image as background

hi,
I'm having a little problem, I don't think it's very difficult but the search on this forum is down a.t.m.
Therefore I'm hoping you guys can help :-)
Like the title already discribes i want to use an Image as background of a JPanel (or on another Frame if it isn't possible on this one) and still be able to put JLabels, JTextfields, etc. on the JPanel with a LayoutManager.
To show what i mean:
-->i want to do something similar to this code
JPanel test=new JPanel(new BorderLayout()));
test.setBackground(Color.WHITE);
--->but instead of setting a Color as Background i want to set an Image :)
greetings

The search facility may be down, but you are searching the wrong forum anyway. This is a Swing question and should be posted in the Swing forum.
But since you made the effort to search, here is a simple example:
ImageIcon icon = new ImageIcon("???.jpg");
JPanel panel = new JPanel()
     public void paintComponent(Graphics g)
          //  Dispaly image at at full size
          g.drawImage(icon.getImage(), 0, 0, null);
          super.paintComponent(g);
panel.setOpaque( false );

Similar Messages

  • Using image as background of frame

    I have a JFrame. I want to add an image (created from a jpeg file) on it as a background. Then, I will draw on that background.
    Please tell me how can I do.
    I tried to use createImage method from JFrame object
    image = frame.createImage(440,400);
    and then create image from file
    image2 = Toolkit.getDefaultToolkit().getImage(filename);
    Graphics g = image.getGraphics();
    g.drawImage(image2,0,0,null);
    I intend to draw some elements on "image" after that. However, the image doesn't not appear on the frame right at the beginning.
    Please help me.
    Thanks.

    I didn't realize that what I wanted was double buffering and even JPanel supports double buffering. However, I still have a problem.
    Please take a look at my code below.
    public class MyFrame extends JFrame {
        static ImagePanel panel;
        static Image backgroundImage;
        public MyFrame(){
         super("Simulation Program");
        public static void main(String[] args){
            MyFrame frame = new MyFrame();
            frame.setVisible(true);
         backgroundImage = Toolkit.getDefaultToolkit().getImage("background.jpg");
         panel = new ImagePanel();
         getContentPane().add(panel);
            drawOnPanel();
        public void drawOnPanel(){
         Graphics g = panel.pic.getGraphics();
         g.drawImage(backgroundImage,0,0,panel); //does not work!
         g.drawRect(0,0,50,50);//works well
         panel.repaint();
    class ImagePanel extends JPanel {
        boolean firstPaint = true;
        Image pic;
        public void paint(Graphics g) {
              if (firstPaint){
                   pic = createImage(440,400);
              firstPaint = false;
              g.drawImage(pic,0,0,this); //redraw the image
    }My problem is that method drawImage I use to draw the background image on the panel doesn't work. I don't know why.
    If I assign the image to pic member of ImagePanel as such:
           pic = backgroundImage;instead of pic = createImage(x,y); the background image appears.
    However, if I do that, I cannot call this following method in drawOnPanel():
          g = panel.pic.getGraphics();because it is said that "You may call getGraphics() only with offscreen image". Then, I cannot add more graphics on the background.
    Thanks for your time.

  • Using image as background to Swing JPanel

    Hi,
    Have been trying to set background of JPanel to an image but cannot get it to work.
    Any ideas why not?! Here is the code Ive written:
    public Simple_Gui()
    //add the title for the frame
    super("Simple frame");
    this.getContentPane().setLayout(new FlowLayout());
    //add a window listener to close the window when the button is pressed
    this.addWindowListener(new WindowAdapter()
         public void windowClosing(WindowEvent we)     
              System.exit(0);
    //need a pane to hold the background image and buttons
         pane = createPanel();
    //this is the background image for the app to make it look lurrrvely
    ImageIcon imageIcon = new ImageIcon( "C://SDF_image.jpg" );
    //set the size of the Panel to the size of our image
    paneHeight = imageIcon.getIconHeight();
    paneWidth = imageIcon.getIconWidth();
    pane.setSize(paneWidth, paneHeight);
    //add the pane to the JFRAME so that it is visible
    this.getContentPane().add(BorderLayout.CENTER, pane);
    this.setVisible(true);
         public static JPanel createPanel()
              JPanel panel = new JPanel()
                   public void paintComponent(Graphics g)
              ImageIcon img = new ImageIcon("C://SDF_image.jpg");               Image image = img.getImage();
                   g.drawImage(image, 0, 0, this);                         super.paintComponent(g);                              }
              panel.setOpaque(false);
              panel.setLayout(new GridLayout(20, 4, 10, 10));
              panel.setVisible(true);
              return panel;
              public static void main(String[] args)
                   Smarty_Gui gui = new Smarty_Gui();
    Sorry about the indentation and format

    Something like this ...
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    public class UsingImageBackground extends JFrame {
    JPanel panel;
    JButton button = new JButton("OK!");
         public UsingImageBackground() {
       Container c = getContentPane();
         panel = new JPanel() {
              public void paintComponent(Graphics g)     {
                   ImageIcon img = new ImageIcon("new.jpg");
                   g.drawImage(img.getImage(), 0, 0, null);
                   super.paintComponent(g);
         panel.setOpaque(false);
         panel.add(button);
       c.add(panel);
         public static void main(String [] args){
              UsingImageBackground frame = new UsingImageBackground();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setSize(160, 120);
              frame.setVisible(true);
    }

  • How can I make an image tile length of browser without using it as background image?

    I understand that if you use the rectangle tool and stretch it to the edge of the page, triggerring the red margin, the tiled image is supposed to stretch the length of the browser. Although this works for width, tiling horizontally, for some reason, it doesn't work for length, tiling vertically. When I preview my work in browser, the tiled image doesn't extend along with the footer as I scroll down the page.
    When I use the image as background fill and tile it, then it works, but I need to use a different image for the background.

    Hi
    As you have mentioned you can either use browser fill with tile fitting or design the browser background image outside of Muse using any image editor like Photoshop and then use as browser fill which would include both images the one you want to use as background image and the one that you want to use as Tile on page section.
    Thanks,
    Sanjit

  • Using images with transparent backgrounds

    Hello. I'm trying to design several forms using a large background graphic along with several other overlays (defined by the form user) that contain transparent backgrounds. Unfortunately, everytime I go to change the graphic, the program won't recognize the transparency of the overlay and substitutes white in it's place. So, for example, I have a background image that is rectangular and when my form user selects an overlay that is circular, it inserts the circle with a white background (which is supposed to be transparent). Can anyone help me with this?
    Thanks!
    -Mike

    Min required version of flash player for my application is 9..
    I think I figured it out, Here is my solution:
    private function completeHandler(evt:Event):void
       var originalWidth:int=loaderG.content.width;
       var originalHeight:int=loaderG.content.height;
       var scale:Number = 0.5;
       var matrix:Matrix = new Matrix();
       matrix.scale(scale, scale);
       myBitmapDataObj=new BitmapData(originalWidth, originalHeight, true, 0xFFFFFF);
       myBitmapDataObj.draw(loaderG.content, null, null, null, null, true);
       var copyBitmapData:BitmapData= new BitmapData(originalWidth* scale, originalHeight* scale, true, 0x000000);
       copyBitmapData.draw(myBitmapDataObj, matrix, null, null, null, true);
       var myBitmapG:Bitmap=new Bitmap(copyBitmapData,PixelSnapping.AUTO,true);
       addChild(myBitmapG);
    I also try blur filter on my bitmap:
    var blur:BlurFilter = new BlurFilter();
       blur.blurX = 1.4;
       blur.blurY = 1.4;
       blur.quality = BitmapFilterQuality.HIGH;
       myBitmapG.filters = [blur];
    Or is there better solution?

  • How can I use an image as background for the entire page?

    With CSS mill, the solid color was defined in the color.X.property file and there is no place to define an image to use as the background? Is it doable to use an image as the background for teh entire page? If so, where to add it and how to implement? Thank you!
    Hao Pan ([email protected])

    While I have been able to add the image to a JLabel and insert it into frames, so that it looks like a suitable background, I have found it impossible to place any other component over the top of said imageDid you set a layout manager for the label?
    Check out the [Background Panel|http://www.camick.com/java/blog.html?name=background-panel] for two different solutions depending on your exact requirement.

  • Using "Image/Transform/Perspective" on a layer?

    Hi,
    I'm new at this.  I have a shot of a big room with empty art frames on the walls.  I have rectangular layers that are shots of paintings that I want to drop into the frames, but of course the paintings layers have to be skewed to show the perspective angle (trapezoid) that matches the room.  Problem is, it seems that I can only use Image/transform/perspective on the painting files before they become layers.  This means guessing the perspective, then moving them into the background, which is trial&error at best.  It's very hard to guess the appropriate perspective when the file isn't a layer. It seems that once the painting files become layers, the "perspective" option is no longer available.  I can use "skew," or "free transform," but not "perspective."    "Skew" doesn't work, because while it will allow changing the rectangle into a paralellogram, it won't allow me to change the rectangle into a trapezoid. "Free Transform" doesn't work for the same reason.  So, How do you apply the "perspective" function to a layer?
    If I knew how to change the rectangle by grabbing one of a selection's corner anchor boxes and fixing it place, that would help because I could create my own trapezoid, but I don't know how to do that.  Does anyone?
    Thanks!

    I've no idea why all the transform options aren't available; they are here.
    Anyway, try this:
    Drag or copy/paste the painting in. It will come in as a new layer.
    Convert that layer to a smart object (Layer > Smart Object > Convert..). Reduce the smart object opacity to 50%.
    Choose Transform > Distort and move the corners individually into place.
    When you're happy, set opacity back to 100% and rasterize the smart object.
    The beauty of the smart object in this case is that you can transform repeatedly without any additional quality loss; it will be rendered only once when you rasterize.

  • How do you make an image a background image if the menu option is dimmed?

    I'm using the Cork Board template in a Pages layout document. I wanted to use the cork background in another page. Option dragging the cork image creates a copy in the new page. I can "Send it to back" but the Arrange->Send Object to Background command is dimmed. The problem is that "Send it to back" does not put it behind the header or footer so my page numbers are not visible.
    Oddly, if I just drag the cork image from one page to another, it remains a background object in the new page. Copying it causes it to come out of the background.
    Anybody have an idea why the Send Object to Background command is dimmed?

    In fact, my guess is that the cork.pdf object is a background object because it is a template transferred from Pages '06 to Pages '08.
    During the conversion, some properties are passed even if they aren't treated by the new version.
    If some one wish to let some of these items in the true background, as far as I know, the only available soluce is:
    create a new object from the delivered template
    unlock some items if necessary
    remove useless items
    lock back the kept item
    save the document as a template.
    Never change the background property of the kept items.
    As far as an item is a "true background" one,
    trying to move an other item to the background will leave it above the "true background object".
    Yvan KOENIG (from FRANCE mardi 9 septembre 2008 15:49:21)

  • Using images with Transparency in Photobooks

    I'm to a point where I would like to use images that utilize transparency in Aperture photo books. Is this possible? So far, PSD files that I've cropped with PS's lasso tools to have transparent areas surrounding their subject tend to change this area to white when dropped into a book.
    Does anyone know of a way or format to use to retain this transparency? I love the speed of Aperture's photobook tools, along with export and printing options, and would like to be able to layer images that bleed together, or have a cut-out subject on top of others, but I haven't noticed a way as of yet.
    Is this ability even available in Aperture yet?
    If not, is there a third party plugin that gives it to the user when making photo books?
    Please let me know soon, else i'm going to have to adjust my workflow back to photoshop only for page set layouts and the created PSD files on blank book pages- not fun.

    i have been trying different ways to make it work fine, and find several things to consider:
    Note: for the next ways i tried with images with transparency.
    1 searching images in the iPad with safari and saving it into Photo app
    then copying it with the popup and pasting it with the popup inside Pages or Keynote:
    work fine.
    2 using the saved images that worked fine in the first way but
    then inside Pages in my opened document, using the menu to import the image from the
    Photo app, to insert the same downloaded image used in the first case:
    does not work, the image appears with a white background.
    3 trying the first way (manually copying and pasting) but with the images i imported from
    my MacBook Pro using the normal way via iTunes(10.1.1 (4))
    does not work, some images appears with a black background, other images
    appears with a white background.
    4 trying with the images of the third way, but changing the method using the photo app
    menu from Pages
    does not work as in the third way
    i dont have problem using transparency images in the first complex way.
    my problem is when i try to use images with transparency in the other three normal ways.

  • Using images in Spry menus

    Can someone please point me to instructions on how to incorporate button images in horizontal Spry menus?

    Here's the working model for the menu I created using images for the main menu tabs: http://mmfc.org/HomePage_CleanUp/index_working.html. And here is the style sheet: http://mmfc.org/HomePage_CleanUp/SpryAssets/working.css.
    I have one remaining problem, and hope someone can help.
    There are three states/images for the main menu tabs: normal state, hover state (when the cursor is over the tab), and visible state (when a submenu is open and the cursor is over a submenu item).
    In OS10.6.4/Safari, it works correctly:
    Normal state
    Hover state
    Visible state
    In Windows XP/IE 6, the 3rd state works incorrectly -- the hover state doesn't get replaced by the visible state:
    In OS10.6.4/Opera and OS10.6.4/Firefox, it also works incorrectly -- but this time the hover state gets replaced by the hover color, not the visible state image:
    For reference, I've copied the CSS below.
    @charset "UTF-8";
    /* SpryMenuBarHorizontal.css - Revision: Spry Preview Release 1.4 */
    /* Copyright (c) 2006. Adobe Systems Incorporated. All rights reserved. */
    LAYOUT INFORMATION: describes box model, positioning, z-order
    /* The outermost container of the Menu Bar, an auto width box with no margin or padding */
    ul.MenuBarHorizontal {
    margin: 0;
    padding: 0;
    list-style-type: none;
    font-size: 100%;
    cursor: default;
    float: right;
    /* Set the active Menu Bar with this class, currently setting z-index to accomodate IE rendering bug: http://therealcrisp.xs4all.nl/meuk/IE-zindexbug.html */
    ul.MenuBarActive {
    z-index: 1000;
    /* Menu item containers, position children relative to this container and are a fixed width */
    ul.MenuBarHorizontal li {
    margin: 0;
    padding: 0;
    list-style-type: none;
    font-size: 100%;
    position: relative;
    text-align: left;
    cursor: pointer;
    width: auto;
    float: left;
    /* Submenus should appear below their parent (top: 0) with a higher z-index, but they are initially off the left side of the screen (-1000em) */
    ul.MenuBarHorizontal ul {
    margin: 0;
    padding: 0;
    list-style-type: none;
    font-size: 100%;
    z-index: 1020;
    cursor: default;
    width: auto;
    position: absolute;
    left: -1000em;
    background-color: #FDE9BB;
    /* Submenu that is showing with class designation MenuBarSubmenuVisible, we set left to auto so it comes onto the screen below its parent menu item */
    ul.MenuBarHorizontal ul.MenuBarSubmenuVisible {
    left: auto;
    /* Menu item containers are variable width according to submenu item text */
    ul.MenuBarHorizontal ul li {
    width: auto;
    /* Submenus should appear slightly overlapping to the right (95%) and up (-5%) */
    ul.MenuBarHorizontal ul ul {
    position: absolute;
    margin: -5% 0 0 95%;
    /* Submenu that is showing with class designation MenuBarSubmenuVisible, we set left to 0 so it comes onto the screen */
    ul.MenuBarHorizontal ul.MenuBarSubmenuVisible ul.MenuBarSubmenuVisible {
    left: auto;
    top: 0;
    DESIGN INFORMATION: describes color scheme, borders, fonts
    /* No borders on all sides */
    /* ul.MenuBarHorizontal ul
    border: 1px solid #666666;
    /* Menu items are a light colored block with no padding and no text decoration */
    ul.MenuBarHorizontal a {
    font-family: Arial, Helvetica, sans-serif;
    font-weight: bold;
    white-space: nowrap;
    text-decoration: none;
    display: block;
    cursor: pointer;
    color: #000000;
    padding-right: 0px;
    padding-left: 0px;
    padding-top: 0px;
    padding-bottom: 0px;
    font-size: 11px;
    /* For setting the background color of the spry menu you need to edit the background in the CSS pane. Click on the spry menu bar and then open up the CSS pane. Window > CSS Styles. There's a few CSS items that set the background by default. The "a" item sets the background for the items that don't have a dropdown and the MenuBarItemSubmenu sets the background for the items that have a dropdown. You can set the background to an image just like you would any other element in your HTML. */
    /* The following selectors define images for the (orange) normal state of tabs */
    ul.MenuBarHorizontal a #AboutUs {
    background-image: url(../img/DropDownMenu_aboutus.gif);
    ul.MenuBarHorizontal a #Missions {
    background-image: url(../img/DropDownMenu_missions.gif);
    ul.MenuBarHorizontal a #Help {
    background-image: url(../img/DropDownMenu_help.gif);
    ul.MenuBarHorizontal a #NewsAndEvents {
    background-image: url(../img/DropDownMenu_newsandevents.gif);
    ul.MenuBarHorizontal a #Media {
    background-image: url(../img/DropDownMenu_media.gif);
    ul.MenuBarHorizontal a #PatientStories {
    background-image: url(../img/DropDownMenu_patientstories.gif);
    ul.MenuBarHorizontal a #ContactUs {
    background-image: url(../img/DropDownMenu_contactus.gif);
    /* The following selectors define images for the (bright) active state of tabs.*/
    ul.MenuBarHorizontal a.MenuBarItemSubmenuHover #AboutUs, ul.MenuBarHorizontal a.MenuBarItemHover #AboutUs, ul.MenuBarHorizontal a.MenuBarSubmenuVisible #AboutUs {
    background-image: url(../img/DropDownMenu_aboutus_vis.gif);
    ul.MenuBarHorizontal a.MenuBarItemSubmenuHover #Missions, ul.MenuBarHorizontal a.MenuBarItemHover #Missions, ul.MenuBarHorizontal a.MenuBarSubmenuVisible #Missions {
    background-image: url(../img/DropDownMenu_missions_vis.gif);
    ul.MenuBarHorizontal a.MenuBarItemSubmenuHover #Help, ul.MenuBarHorizontal a.MenuBarItemHover #Help, ul.MenuBarHorizontal a.MenuBarSubmenuVisible #Help {
    background-image: url(../img/DropDownMenu_help_vis.gif);
    ul.MenuBarHorizontal a.MenuBarItemSubmenuHover #NewsAndEvents, ul.MenuBarHorizontal a.MenuBarItemHover #NewsAndEvents, ul.MenuBarHorizontal a.MenuBarSubmenuVisible #NewsAndEvents {
    background-image: url(../img/DropDownMenu_newsandevents_vis.gif);
    ul.MenuBarHorizontal a.MenuBarItemSubmenuHover #Media, ul.MenuBarHorizontal a.MenuBarItemHover #Media, ul.MenuBarHorizontal a.MenuBarSubmenuVisible #Media {
    background-image: url(../img/DropDownMenu_media_vis.gif);
    ul.MenuBarHorizontal a.MenuBarItemSubmenuHover #PatientStories, ul.MenuBarHorizontal a.MenuBarItemHover #PatientStories, ul.MenuBarHorizontal a.MenuBarSubmenuVisible #PatientStories {
    background-image: url(../img/DropDownMenu_patientstories_vis.gif);
    ul.MenuBarHorizontal a.MenuBarItemSubmenuHover #ContactUs, ul.MenuBarHorizontal a.MenuBarItemHover #ContactUs, ul.MenuBarHorizontal a.MenuBarSubmenuVisible #ContactUs {
    background-image: url(../img/DropDownMenu_contactus_vis.gif);
    /* The following selectors define images for the (red) hover state of tabs.*/
    ul.MenuBarHorizontal a:hover #AboutUs, ul.MenuBarHorizontal a:focus #AboutUs {
    background-image: url(../img/DropDownMenu_aboutus_hover.gif);
    ul.MenuBarHorizontal a:hover #Missions, ul.MenuBarHorizontal a:focus #Missions {
    background-image: url(../img/DropDownMenu_missions_hover.gif);
    ul.MenuBarHorizontal a:hover #Help, ul.MenuBarHorizontal a:focus #Help {
    background-image: url(../img/DropDownMenu_help_hover.gif);
    ul.MenuBarHorizontal a:hover #NewsAndEvents, ul.MenuBarHorizontal a:focus #NewsAndEvents {
    background-image: url(../img/DropDownMenu_newsandevents_hover.gif);
    ul.MenuBarHorizontal a:hover #Media, ul.MenuBarHorizontal a:focus #Media {
    background-image: url(../img/DropDownMenu_media_hover.gif);
    ul.MenuBarHorizontal a:hover #PatientStories, ul.MenuBarHorizontal a:focus #PatientStories {
    background-image: url(../img/DropDownMenu_patientstories_hover.gif);
    ul.MenuBarHorizontal a:hover #ContactUs, ul.MenuBarHorizontal a:focus #ContactUs {
    background-image: url(../img/DropDownMenu_contactus_hover.gif);
    /* Menu items that have mouse over or focus have a dark background and white text */
    ul.MenuBarHorizontal a:hover, ul.MenuBarHorizontal a:focus {
    background-color: #bf2e1a;
    color: #FFFFFF;
    /* Menu items that are open with submenus are set to MenuBarItemHover with a dark background and white text */
    ul.MenuBarHorizontal a.MenuBarItemHover, ul.MenuBarHorizontal a.MenuBarItemSubmenuHover, ul.MenuBarHorizontal a.MenuBarSubmenuVisible {
    background-color: #bf2e1a;
    color: #FFFFFF;
    /* Sets width of submenus and makes text non-wrapping  */
    ul.MenuBarHorizontal ul li {
    display: block;
    float: none;
    width: 12em;
    white-space: nowrap;
    SUBMENU INDICATION: styles if there is a submenu under a given menu item
    /* Menu items that have a submenu have the class designation MenuBarItemSubmenu and are set to use a background image positioned on the far left (95%) and centered vertically (50%) */
    ul.MenuBarHorizontal a.MenuBarItemSubmenu {
    /* background-image: url(SpryMenuBarDown.gif); */
    background-repeat: no-repeat;
    background-position: 95% 50%;
    /* Menu items that have a submenu have the class designation MenuBarItemSubmenu and are set to use a background image positioned on the far left (95%) and centered vertically (50%) */
    ul.MenuBarHorizontal ul a.MenuBarItemSubmenu {
    /* background-image: url(SpryMenuBarRight.gif); */
    background-repeat: no-repeat;
    background-position: 95% 50%;
    /* Menu items that are open with submenus have the class designation MenuBarItemSubmenuHover and are set to use a "hover" background image positioned on the far left (95%) and centered vertically (50%) */
    ul.MenuBarHorizontal a.MenuBarItemSubmenuHover {
    /* background-image: url(SpryMenuBarDownHover.gif); */
    background-repeat: no-repeat;
    background-position: 95% 50%;
    /* Menu items that are open with submenus have the class designation MenuBarItemSubmenuHover and are set to use a "hover" background image positioned on the far left (95%) and centered vertically (50%) */
    ul.MenuBarHorizontal ul a.MenuBarItemSubmenuHover {
    /* background-image: url(SpryMenuBarRightHover.gif); */
    background-repeat: no-repeat;
    background-position: 95% 50%;
    BROWSER HACKS: the hacks below should not be changed unless you are an expert
    /* HACK FOR IE: to make sure the sub menus show above form controls, we underlay each submenu with an iframe */
    ul.MenuBarHorizontal iframe {
    position: absolute;
    z-index: 1010;
    /* HACK FOR IE: to stabilize appearance of menu items; the slash in float is to keep IE 5.0 from parsing */
    @media screen, projection {
    ul.MenuBarHorizontal li.MenuBarItemIE {
    display: inline;
    /* f\loat: left;
    background: #FFF; */

  • I have a jpg file that I must use as a background in a Dreamweaver project. There is some text embed

    I have a jpg file that I must use as a background in a Dreamweaver project. There is some text embedded in it that I can't edit. I have tried using Illustrator and Photoshop but I lack experience so I'm probably missing something. I'd be glad of some help as this is all that is preventing me from marking it as complete. The file address is lecaff.fr/images/home_banner.jpg Thank you in anticipation.

    Use Photoshop and the Stamp tool (S) to get rid of the lettering.
    Do little areas at a time, constantly changing the sampling point if you want a half decent job.
    Also, don’t use a .jpg format for files with lettering.
    If you must have lettering use .psd, .tif, .png or some other non-lossy format.

  • How to update the large amount of thumbnail images in background process

    in my application i want to load large number of thumbnail images(each images set as icon for separate jradiobutton) into panel. This panel is in left side of JSplitPane.
    when application is starting, now I’m loading the thumbnail buttons without image(to run the application quickly).
    now i want to update the buttons with real thumbnail images in background. i tried with thread and SwingUtilities.invokeLater ,but it stuck the application until updating finish.
    Note:im using java1.4 (not in the possession to use other versions)
    Can anybody give suggestion?
    SwingUtilities.invokeLater(new Runnable() {
    public void run() {
         for (int j = 0; j < imgPagesV.size(); j++) {
         try {
              ImageIcon icon = new ImageIcon((BufferedImage)thumImagesV.get(j)); //thumImagesV vector have thumnail bufferedimages 
              ((JRadioButton)thumButtonPanel.getComponent(j)).setIcon(icon);
              updateUI();
         } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
    });

    thax for your reply ..
    even i call new smiple thread to load the images it freeze the main gui. is any wrong in my way ?
    Thread Class
    import javax.media.jai.NullOpImage;
    import javax.media.jai.OpImage;
    import com.sun.media.jai.codec.ImageCodec;
    import com.sun.media.jai.codec.ImageDecoder;
    import com.sun.media.jai.codec.TIFFDecodeParam;
    public class TestThread extends Thread {
         File tiffImg;
         TestThread(File img) {
              this.tiffImg = img;
          * extracting form tiff images and creates thumbnail then add into vector
         public void run() {
              ImageDecoder dec = null;
              Vector thumImagesV = new Vector();
              TIFFDecodeParam param = new TIFFDecodeParam();
              param.setDecodePaletteAsShorts(true);
              param.setJPEGDecompressYCbCrToRGB(true);
              try {
                   dec = ImageCodec.createImageDecoder("tiff", tiffImg, param);
                   int start, end = 0;
                   for (int i = 0; i < dec.getNumPages(); i++) {
                        RenderedImage rm = new NullOpImage(dec.decodeAsRenderedImage(i), null, OpImage.OP_IO_BOUND, null);
                        thumImagesV.add(i, ImageHandler.createThumbnail(rm, 150));
              } catch (Exception e) {
                   e.printStackTrace();
    Main GUI Class
         private void buildGUI(File selectedFile) {
              configButtonPanel();
              configThumbnailPanel(selectedFile);//loading with out thumbnail image
              new TestThread(selectedFile).run();
         }

  • How to count number of vehicles using image processing tools in LabVIEW

    anyone can give me idea that how to do counting of vehicles using image processing tools

    Hello,
    if camera is stationary, first take an image of the background. Then subtract each acquired image from the reference image. Limit the region of interest - build a mask of the area, where you want to detect vehicles. Use only the pixels that are under the mask for further processing. You probably would need to do some morphological operations (for example dilate) to make the detection more noise-free...
    Maybe you could get more reference images (different time of day) and compare the average intensities of the acquired and the reference image to select the best image for subtraction.
    You could then probably just count the numer of objects to get the number of vehicles.
    You can perhaps also use optical flow to track the vehicles, but you would need to compute some features for example strong corners for each vehicle (check good features to track, http://docs.opencv.org/modules/imgproc/doc/feature_detection.html). Or you can use the new mean-shift tracking library (Labview 2013).
    Hope this helps a bit.
    Best regards,
    K
    https://decibel.ni.com/content/blogs/kl3m3n
    "Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."

  • Image for background

    I have an image now that I want to use for a background on
    all of my WebPages. The image size is 2912x 4368 and I have made it
    1024x1536. On the page it looks good but what happens is the image
    repeats itself twice for width and length. I want it to only stay
    as one image no matter what resolution it is viewed as and not
    repeat the image for either length or width. Plus not look
    stretched or distorted.
    I am using Dream Weaver MX version 6 and also have Adobe PS
    CS2, any questions just ask.
    How do I achieve this?
    Thanks

    Why so huge? What is the weight of that monster?
    > I want it to only stay as one image no matter what
    resolution
    This is not a resolution issue. It's a browser window size
    issue (and
    always has been). When you say "stay as one image", do you
    mean "not tile",
    or do you mean "fill the entire width and height"? If the
    latter, then you
    cannot do that with a background image. Background images
    tile, they don't
    stretch. You can prevent the tiling with a little CSS -
    body { background-repeat:no-repeat; }
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "568jfe56nfg" <[email protected]> wrote in
    message
    news:fn33r3$a9a$[email protected]..
    > I have an image now that I want to use for a background
    on all of my
    > WebPages. The image size is 2912x 4368 and I have made
    it 1024x1536. On
    > the
    > page it looks good but what happens is the image repeats
    itself twice for
    > width
    > and length. I want it to only stay as one image no
    matter what resolution
    > it is
    > viewed as and not repeat the image for either length or
    width. Plus not
    > look
    > stretched or distorted.
    >
    > I am using Dream Weaver MX version 6 and also have Adobe
    PS CS2, any
    > questions
    > just ask.
    >
    > How do I achieve this?
    >
    > Thanks
    >
    >

  • Brush stroke pattern that i want to use as a background in Photoshop CS4.

    I've painted a piece of paper with a brush stroke pattern that i want to use as a background in Photoshop CS4. I know how to make a fill layer and apply a colour to a shape, but can you do this for a pattern you've made? I also want to make the pattern a certain pink, and select an elipse in the middle which would just be a different colour section of the same pattern. Is this possible?

    so this first is the pattern/image i want to change the colour of:
    and below is how i want the colour changes to be specified to the two areas created by this elipse shape: i want to apply that sort of shape and colour differentiation to the texture/pattern/shape of the brush strokes.

Maybe you are looking for