Display a transparent image in JPanel

i just start using Java Graphics Programming fews month ago. there's some problem i facing recently. i doing a simple gif file viewer. first i get the file using the Toolkit and put it in a Image object and use the Gif Decoder to decoded each frame of the Gif File to BufferedImage object and display each of the frame in a JPanel inside a JFrame.My porblem is :-
How to display a transparent image in JPanel? my image source in BufferedImage and how to i know the image is transparent or not?

I simply use ImageIcon object to display the image (*.gif,*.jpg)
JLabel l=new JLabel(new ImageIcon("file path"));
add the label to a panel or frame or dialog
this object no need to use the ImageBuffered Object
It can display any animate gif whether the background is transparent or not.

Similar Messages

  • How to read and display a fits image into JPanel

    Hi,I currently want to read a .fits file and display it in JPanel,have no idea how to achieve it.Any suggestions and source codes are appreciated.Thanks in advance!

    fits stands for flexible image transport system,it defined only for astronomy image data.it is not normal image,I am afraid I can not use the way you said to read fits file.Anyway,thanks a lot.

  • Transparent image problem

    Hi all,
    I have two images of the world, both of exactly the same size. The first is a background, and provides texture. The second image goes on top and is supposed to be transparent to let the texture show through. My problem is that when i display the 'transparent' image on top, you cannot see the contours through it, instead the top image just appears a pale colour because of the transparency added to it, as opposed to actually being transparent. Here is my code:
    import java.awt.*;
    import java.awt.image.*;
    import java.io.*;
    import javax.imageio.*;
    public class GamePane extends Canvas {
        /** Creates a new instance of GamePane */
        public GamePane() {
            try {
                buff1 = ImageIO.read(getClass().getResource("images/map_background.gif"));
                buff2 = ImageIO.read(getClass().getResource("images/map.gif"));
            catch (IOException ioe) {
                System.out.println("Problem reading in file: " + ioe);
        public void paint(Graphics g) {
            g.drawImage(buff1, 0, 0, null);
            g.drawImage(buff2, 0, 0, null); //the transparent image
        Image img;
        BufferedImage buff1;
        BufferedImage buff2;
    }Can anyone suggest where i am going wrong?
    Many thanks

    As I understand you right, you want to use a top layered image with transparent parts. If this is the case, you should use the same color for all transparent parts in the picture and use a paint program to change the transparent color to the color mentioned. I use always microsoft paint to do this. (picture-attributes-transparent...)
    the colored parts will automatically appear transparent.

  • Layering a series of Transparent images onto a JPanel or JLayeredPane

    Hello all -
    I am working on creating a viewfinder type component for a game engine I am developing. Currently, I am loading a BackBuffered image from an array and displaying it in a JPanel. This image essentially serves as the "background" of the viewfinder.
    What I would like to do is go one step further and after the background image is determined, load a series of transparent images and place those on top of the background, BEFORE the repaint() method is called. An example of this would be loading the background image, and then loading walls (or other sprites), firing the repaint() method, resulting in the rendering all the images at one time.
    I have looked into JLayeredPane, but am uncertain as to whether this is the correct avenue to pursue. Does anyone have any experience with this?
    Any assistance would be greatly appreciated.

    JLayeredPane is not the way to go. Just draw your images on a panel. If you want/need to do all the drawing before repainting, use a back buffer. See BufferedImage

  • Need to display image on JPanel

    Hello
    I am trying to implement a graphical version of the Knights Tour. I am done with the algorithm part of the problem itself. I am having problem with displaying the chess board. Although seemingly straightforward the images will not display on the JPanel. Below is a sample of what I am trying to do. Can anyone explain why the code does not work even though it seems okay. Thanks and best regards.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    public class test extends JFrame { 
    public test(){ 
    panel pane = new panel();
    getContentPane().add(pane);
    public static void main(String[]args){   
    test tst = new test();
    tst.setSize(500,500);
    tst.show();
    public class panel extends JPanel{   // inner class
    private Image img;
    private ImageIcon icon;
    public panel(){
    icon = new ImageIcon("cross.gif");
    img = icon.getImage();
    public void paintComponent(Graphics g)
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D)g;
    System.out.println("I am here");
    g.drawImage(img,40,40,this);
    }

    package com.lc.util.swing ;
    import java.awt.Color ;
    import java.awt.Graphics ;
    import java.awt.Image;
    import java.awt.Insets;
    import java.awt.Dimension ;
    import java.awt.image.ImageObserver ;
    import javax.swing.JPanel;
    import javax.swing.border.Border;
    * Panel displaying an {@link Image}.
    * <ul>
    * <li>8 positions,</li>
    * <li>
    * can stretch image for filling the whole available area, or diminish
    * its size if too large in width or height,
    * </li>
    * <li>respects borders (as defined by
    * {@link javax.swing.JComponent#setBorder( javax.swing.border.Border ) JComponent.setBorder}
    * </li>
    * </ul>
    * @author Laurent Caillette
    * @version $Revision: 1.1.1.1 $ $Date: 2002/02/19 22:12:04 $
    public class JImagePanel extends JPanel {
    public JImagePanel() {
    imageObserver = this ;
    * Constructeur assignant une image.
    public JImagePanel( Image image ) {
    this() ;
    setImage( image ) ;
    private Image image ;
    private ImageObserver imageObserver ;
    public void setImage( Image image ) {
    this.image = image ;
    adjustPreferredSize();
    public void setBorder( Border newBorder ) {
    super.setBorder( newBorder ) ;
    adjustPreferredSize() ;
    private void adjustPreferredSize() {
    if( image != null ) {
    int w = image.getWidth( imageObserver ) ;
    int h = image.getHeight( imageObserver ) ;
    Border border = getBorder() ;
    if( border != null ) {
    Insets insets = border.getBorderInsets( this ) ;
    if( insets != null ) {
    w += ( insets.left + insets.right ) ;
    h += ( insets.top + insets.bottom ) ;
    Dimension dim = new Dimension( w, h ) ;
    this.setPreferredSize( dim ) ;
    private int placement = CENTER ;
    public int getPlacement() { return placement ; }
    public void setPlacement( int placement ) {
    if( ( placement < CENTER ) || ( placement > STRETCH ) ) {
    throw new IllegalArgumentException( "Unsupported placement value" ) ;
    this.placement = placement ;
    public void paint( Graphics gr ) {
    // x of Image to draw
    int x ;
    // y of Image to draw
    int y ;
    // width of Image to draw
    int iw ;
    // height of Image to draw
    int ih ;
    // thickness of left border
    int bl = 0 ;
    // thickness of upper border
    int bt = 0 ;
    // thickness of right border
    int br = 0 ;
    // thickness of lower border
    int bb = 0 ;
    // width of drawable area
    int pw = this.getWidth() ;
    // height of drawable area
    int ph = this.getHeight() ;
    // Handle borders
    Insets insets = null ;
    Border border = getBorder() ;
    if( border != null ) {
    insets = getBorder().getBorderInsets( this ) ;
    if( insets != null ) {
    bl = insets.left ;
    br = insets.right ;
    bb = insets.bottom ;
    bt = insets.top ;
    pw = pw - bl - br ;
    ph = ph - bt - bb ;
    // Always display background, for supporting transparency.
    super.paint( gr ) ;
    if( image != null ) {
    iw = image.getWidth( imageObserver ) ;
    ih = image.getHeight( imageObserver ) ;
    if( ( placement == STRETCH ) ||
    ( iw > pw ) ||
    ( ih > ph )
    gr.drawImage(image, bl, bt, pw, ph, imageObserver ) ;
    } else {
    iw = image.getWidth( imageObserver ) ;
    ih = image.getHeight( imageObserver ) ;
    switch( placement ) {
    case CENTER :
    x = ( pw - iw ) / 2 ;
    y = ( ph - ih ) / 2 ;
    break ;
    case NORTH :
    x = ( pw - iw ) / 2 ;
    y = 0 ;
    break ;
    case NORTHEAST :
    x = pw - iw ;
    y = 0 ;
    break ;
    case EAST :
    x = pw - iw ;
    y = (ph - ih ) / 2 ;
    break ;
    case SOUTHEAST :
    x = pw - iw ;
    y = ph - ih ;
    break ;
    case SOUTH :
    x = ( pw - iw ) / 2 ;
    y = ph - ih ;
    break ;
    case SOUTHWEST :
    x = 0 ;
    y = ph - ih ;
    break ;
    case WEST :
    x = 0 ;
    y = ( ph - ih ) / 2 ;
    break ;
    case NORTHWEST :
    x = 0 ;
    y = 0 ;
    break ;
    default :
    throw new IllegalArgumentException(
    "Unsupported placement value" ) ;
    // Add border offset
    x += bl ;
    y += bt ;
    gr.drawImage( image, x, y, this ) ;
    public final static int CENTER = 0 ;
    public final static int NORTH = 1 ;
    public final static int NORTHEAST = 2 ;
    public final static int EAST = 3 ;
    public final static int SOUTHEAST = 4 ;
    public final static int SOUTH = 5 ;
    public final static int SOUTHWEST = 6 ;
    public final static int WEST = 7 ;
    public final static int NORTHWEST = 8 ;
    public final static int STRETCH = 9 ;

  • Having trouble displaying image in JPanel

    I want to display an image in jpanel making it to scale to the size of the panel.
    And later i should be able to draw on that image , i am really new to all this , but i have to finish it soon.
    This is the code i am compiling and getting error
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class LocaterClient extends JFrame
         JPanel panel;
         public LocaterClient()
              super("LocaterClient");
              panel = new JPanel();
              panel.setSize(374,378);
              panel.setOpaque(false);
              panel.setVisible(true);
         getContentPane().add(panel);
         /*JFrame f = new JFrame();
         f.setSize(374,378);
         f.getContentPane().add(panel);*/
         public void paintComponent(Graphics g)
              super.paintComponent(g);
              ImageIcon img = new ImageIcon("World_MER.jpg");
              ImageIcon fillImage = new ImageIcon(img.getImage().getScaledInstance
    (getWidth(), getHeight(),Image.SCALE_REPLICATE));
              g.drawImage(fillImage.getImage(), 0,0, this);
         public static void main(String args[])
              LocaterClient lc = new LocaterClient();
              lc.setDefaultCloseOperation( EXIT_ON_CLOSE );
              lc.pack();
              lc.setVisible(true);
    This is the error i am getting
    LocaterClient.java:24: cannot resolve symbol
    symbol : method paintComponent (java.awt.Graphics)
    location: class javax.swing.JFrame
    super.paintComponent(g);
    ^
    1 error
    If i remove super.paintComponent(g); line it compiles and runs but i get a tiny panel without the image.
    PLease help me , i am not evn sure is this is the procedure should i follow , because i should be able to draw on that image later on .
    Please provide me with some sample code.

    import javax.swing.*;
    import java.awt.*;
    public class ImagePainter extends JPanel{
      private Image img;
      public ImagePainter(){
        img = Toolkit.getDefaultToolkit().getImage("MyImage.gif");
      public void paintComponent(Graphics g){
        g.drawImage(img,0,0,getSize().width,getSize().height);
      public static void main(String[]args){
        JFrame frame = new JFrame();
        frame.getContentPane.add(new ImagePainter());
        frame.setSize(500,500);
        frame.show();

  • Displaying DICOM images in JPanel

    Can anyone please tell me how to display DICOM images using JPanel? I can use JPanel to display ordinary images but it does not seem to work using DICOM images. Can anyone please help me out? I've spent hours and hours trying to solve this problem. Thank you in advance.

    Can anyone please tell me how to display DICOM images
    using JPanel? I can use JPanel to display ordinary
    images but it does not seem to work using DICOM
    images. Can anyone please help me out? I've spent
    hours and hours trying to solve this problem. Thank
    you in advance.The JPanel is only able to display JPEG and GIF images, you will need to decode the DICOM image first and convert to JPEG or GIF format, there are some source codes available on the net. Also check this link out
    http://www.dclunie.com/medical-image-faq/html/part8.html

  • Displaying the content of one JPanel in an other as a scaled image

    Hi,
    I'd like to display the content of one JPanel scaled in a second JPanel.
    The first JPanel holds a graph that could be edited in this JPanel. But unfortunately the graph is usually to big to have a full overview over the whole graph and is embeded in a JScrollPanel. So the second JPanel should be some kind of an overview window that shows the whole graph scaled to fit to this window and some kind of outline around the current section displayed by the JScrollPanel. How could I do this?
    Many thanks in advance.
    Best,
    Marc.

    Hi,
    I'd like to display the content of one JPanel scaled
    in a second JPanel.
    The first JPanel holds a graph that could be edited
    in this JPanel. But unfortunately the graph is
    usually to big to have a full overview over the whole
    graph and is embeded in a JScrollPanel. So the second
    JPanel should be some kind of an overview window that
    shows the whole graph scaled to fit to this window
    and some kind of outline around the current section
    displayed by the JScrollPanel. How could I do this?
    Many thanks in advance.
    Best,
    Marc.if panel1 is the graph and panel2 is the overview, override the paintComponent method in panel2 with this
    public void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.scale(...,...);
    panel1.paint(g2);
    }

  • Adding Image to JPanel?

    Hi all,
    I am new to Swing..
    How to add the "Image" to JPanel.
    if anyone knows please help me..
    Thanks

    Here's a long reply involving several classes, some obtained directly from Sun for reuse. These allow you to fill an image in a panel as the background to your frame. You can add components on top of this background image. If this isn't what you wanted, excuse my misunderstanding:
    First, you need a panel for your frame:
    <code>
    public class FramePanel extends JPanel
    * Initialized by the (first call to the) constructor. This
    * Fill is used to paint the entire panel.
    private static TiledFill tiledFill = null;
    /*Constructors */
    public FramePanel()
    super();
    setOpaque(true);
    * Create a TiledFill object to draw the
    * background from preferences properties file
    public void getBackgroundImage()
    setForeground(Color.BLACK);
    setBackground(Color.WHITE);
    if (tiledFill == null)
    try
    FileImageInputStream file = new FileImageInputStream(*your image's file location*);
    BufferedImage image = ImageIO.read(file);
    ImageFill fill = new ImageFill(image);
    tiledFill = new TiledFill(fill, image.getWidth(), image.getHeight());
    catch (IOException e)
    e.printStackTrace();
    JOptionPane pane = new JOptionPane("Could not retrieve image in FramePanel");
    pane.setVisible(true);
    * Paint the area within <code>g.getClipBounds()</code>
    * making sure that the new tiles are aligned with a tileWidth
    * by tileHeight grid whose origin is at 0,0.
    public void paintComponent(Graphics g)
    super.paintComponent(g);
    getBackgroundImage();
    /* To ensure that the tiles we paint are aligned with
    * a tileWidth X tileHeight grid whose origin is 0,0 we
    * enlarge the clipBounds rectangle so that its origin
    * is aligned with the origin of a tile and its size
    * is a multiple of the tile size.
    Rectangle clip = g.getClipBounds();
    int tw = tiledFill.getTileWidth();
    int th = tiledFill.getTileHeight();
    int x = (clip.x / tw) * tw;
    int y = (clip.y / th) * th;
    int w = (((clip.x + clip.width + tw - 1) / tw) * tw) - x;
    int h = (((clip.y + clip.height + th - 1) / th) * th) - y;
    Graphics gFill = g.create();
    tiledFill.paintFill(this, gFill, new Rectangle(x, y, w, h));
    gFill.dispose();
    </code>
    Now you need the fill and tiled fill classes size the image.
    <code>
    import java.awt.*;
    public class Fill
    public void paintFill(Component c, Graphics g, Rectangle r)
    g.setColor(c.getBackground());
    g.fillRect(r.x, r.y, r.width, r.height);
    public void paintFill(Container c, Graphics g)
    Insets insets = c.getInsets();
    int x = insets.left;
    int y = insets.top;
    int w = c.getWidth() - (insets.left + insets.right);
    int h = c.getHeight() - (insets.top + insets.bottom);
    paintFill(c, g, new Rectangle(x, y, w, h));
    public void paintFill(Component c, Graphics g, int x, int y, int w, int h)
    paintFill(c, g, new Rectangle(x, y, w, h));
    </code>
    <code>
    import java.awt.*;
    import java.awt.image.*;
    * Displays a single <code>BufferedImage</code>, scaled to fit the
    * <code>paintFill</code> rectangle.
    * <pre>
    * BufferedImage image = ImageIO.read(new File("background.jpg"));
    * final ImageFill imageFill = new ImageFill(image);
    * JPanel p = new JPanel() {
    * public c void paintComponent(Graphics g) {
    *     imageFill.paintFill(this, g);
    * </pre>
    * Note that animated gifs aren't supported as there's no image observer.
    public class ImageFill extends Fill
    private final static int IMAGE_CACHE_SIZE = 8;
    private BufferedImage image;
    private BufferedImage[] imageCache = new BufferedImage[IMAGE_CACHE_SIZE];
    private int imageCacheIndex = 0;
    * Creates an <code>ImageFill</code> that draws <i>image</i>
    * scaled to fit the <code>paintFill</code> rectangle
    * parameters.
    * @see #getImage
    * @see #paintFill
    public ImageFill(BufferedImage image)
    this.image = image;
    * Creates an "empty" ImageFill. Before the ImageFill can be
    * drawn with the <code>paintFill</code> method, the
    * <code>image</code> property must be set.
    * @see #setImage
    * @see #paintFill
    public ImageFill()
    this.image = null;
    * Returns the image that the <code>paintFill</code> method draws.
    * @return the value of the <code>image</code> property
    * @see #setImage
    * @see #paintFill
    public BufferedImage getImage()
    return image;
    * Set the image that the <code>paintFill</code> method draws.
    * @param image the new value of the <code>image</code> property
    * @see #getImage
    * @see #paintFill
    public void setImage(BufferedImage image)
    this.image = image;
    for (int i = 0; i < imageCache.length; i++)
    imageCache[i] = null;
    * Returns the actual width of the <code>BufferedImage</code>
    * rendered by the <code>paintFill</code> method. If the image
    * property hasn't been set, -1 is returned.
    * @return the value of <code>getImage().getWidth()</code> or -1 if
    * getImage() returns null
    * @see #getHeight
    * @see #setImage
    public int getWidth()
    BufferedImage image = getImage();
    return (image == null) ? -1 : image.getWidth();
    * Returns the actual height of the <code>BufferedImage</code>
    * rendered by the <code>paintFill</code> method. If the image
    * property hasn't been set, -1 is returned.
    * @return the value of <code>getImage().getHeight()</code> or -1 if
    * getImage() returns null
    * @see #getWidth
    * @see #setImage
    public int getHeight()
    BufferedImage image = getImage();
    return (image == null) ? -1 : image.getHeight();
    * Create a copy of image scaled to width,height w,h and
    * add it to the null element of the imageCache array. If
    * the imageCache array is full, then we replace the "least
    * recently used element", at imageCacheIndex.
    private BufferedImage createScaledImage(Component c, int w, int h)
    GraphicsConfiguration gc = c.getGraphicsConfiguration();
    BufferedImage newImage = gc.createCompatibleImage(w, h, Transparency.TRANSLUCENT);
    boolean cacheOverflow = true;
    for (int i = 0; i < imageCache.length; i++)
    Image image = imageCache;
    if (image == null)
    imageCache[i] = newImage;
    cacheOverflow = false;
    break;
    if (cacheOverflow)
    imageCache[imageCacheIndex] = newImage;
    imageCacheIndex = (imageCacheIndex + 1) % imageCache.length;
    Graphics g = newImage.getGraphics();
    int width = image.getWidth();
    int height = image.getHeight();
    g.drawImage(image, 0, 0, w, h, 0, 0, width, height, null);
    g.dispose();
    return newImage;
    * Returns either the image itself or a cached scaled copy.
    private BufferedImage getFillImage(Component c, int w, int h)
    if ((w == getWidth()) && (h == getHeight()))
    return image;
    for (int i = 0; i < imageCache.length; i++)
    BufferedImage cimage = imageCache[i];
    if (cimage == null)
    break;
    if ((cimage.getWidth(c) == w) && (cimage.getHeight(c) == h))
    return cimage;
    return createScaledImage(c, w, h);
    * Draw the image at <i>r.x,r.y</i>, scaled to <i>r.width</i>
    * and <i>r.height</i>.
    public void paintFill(Component c, Graphics g, Rectangle r)
    if ((r.width > 0) && (r.height > 0))
    BufferedImage fillImage = getFillImage(c, r.width, r.height);
    g.drawImage(fillImage, r.x, r.y, c);
    </code>
    Now it's just a simple matter of creating a frame and making the frame panel the frame's content pane:
    <code>
    import java.awt.BorderLayout;
    import java.awt.HeadlessException;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.UIManager;
    public class ImageFrame extends JFrame
    private FramePanel framePanel;
    //start of constructors
    public ImageFrame() throws HeadlessException
    super();
    init();
    public ImageFrame(String title) throws HeadlessException
    super(title);
    init();
    // end of constructors
    void init()
    try
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    catch (Exception e)
    System.out.println ("Unknown Look and Feel");
         framePanel = new FramePanel();
         this.getContentPane().add(framePanel, BorderLayout.CENTER);
         this.setContentPane(framePanel);
         ((JPanel)this.getContentPane()).setOpaque(false);
    </code>

  • Background Image in JPanel.

    Hi, I am trying to set a background image to my JPanel. So far everything ok. However When I add labels to this panel as well the image is displayed but the label is not! I tried to make a search on google, and I found some links pointing to this forum, however none of them (which) I have seen show how to display a backgroun image and a label on top.
    What I tried to to is override the paint method of the JPanel. Here I did the following code:
    public void paint(Graphics g){
       Image i = this.myImage // Were myImage is of type Image with a loaded image in.
       g = super.getGraphics();
       g.drawImage(i, 0, 0, this);
       super.paint(g);
    }However this code brings the label and the image always blinking. I can imagine the reason for this is that the paint method is called all the time, and thus the image and the label are being painted all the time and so there is the blinking effect.
    Does anyone know how I can set a background image to my JPanel in an efficient way?

    No Gosling? I just retried it and it works for me.
    Maybe you're having trouble with the image URL.
    Try it with a local image.

  • Displyaing image in JPanel

    I am using below code to display image in jpanel.
    It is not displaying image. Please help me.
    import java.util.Vector;
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.Toolkit;
    import java.awt.Image;
    public class project extends JPanel {
         public void init()
              JFrame mFrame = new JFrame("Documentum Login");
              mFrame.setSize(350,200);
    //mFrame.setResizable(false);
    Dimension dim = getToolkit().getScreenSize();
    mFrame.setLocation((dim.width/2) - (mFrame.getWidth()/2),(dim.height/2) - (mFrame.getHeight()/2));
              //JPanel hpan = new JPanel();
    //hpan.setLayout(new BoxLayout(hpan,BoxLayout.Y_AXIS));
    //hpan.setBorder(new TitledBorder (new LineBorder (Color.blue, 1)));
              //Image img = Toolkit.getDefaultToolkit().getImage("D:/Temp/test.jpg");
              ImageIcon icon = new ImageIcon("D:\\Temp\\test.jpg");
              JLabel imageLabel = new JLabel(icon);
              JScrollPane scrollPane = new JScrollPane (JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
              scrollPane.getViewport().add(imageLabel);
              JPanel panel = new JPanel();
              panel.setLayout(new BorderLayout());
              panel.add(scrollPane,BorderLayout.CENTER);
              mFrame.getContentPane().add(panel);
    mFrame.addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent e) {System.exit(0); }
    mFrame.setVisible(true);
         public static void main(String args[])
              project pr = new project();
              pr.init();          
    }

    Don't add() to a JViewport, setView() instead.

  • Firefox wont show transparent images as transparent

    Firefox worked perfectly until a week or so ago it wouldnt open. So I switched to Google Chrome for awhile and missed firefox. haha. So I uninstalled and reinstalled the latest version.
    But now, Firefox will not display transparent images correctly, they all have a white background now. Am I missing a plug-in or update? Or is there something I need to turn on somewhere? Thanks for any answers.

    Do you have website colors enabled?
    Tools > Options > Content : Fonts & Colors: Colors > [X] "Allow pages to choose their own colors, instead of my selections above"
    Your above posted system details show outdated plugin(s) with known security and stability risks.
    # Shockwave Flash 10.0 r32
    # Next Generation Java Plug-in 1.6.0_17 for Mozilla browsers
    Update the [[Java]] plugin to the latest version.
    *http://java.sun.com/javase/downloads/index.jsp (Java Platform: Download JRE)
    Update the [[Managing the Flash plugin|Flash]] plugin to the latest version.
    *http://www.adobe.com/software/flash/about/

  • Putting an Image in JPanel

    I am trying to put an image in JPanel. Using something other than ImageIcon. When I run the program only a white screen appears.
    package game;
    import gui.FullScreenDisplay;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.lang.Runnable;
    import java.lang.Thread;
    public class Runner implements Runnable
         private static final long serialVersionUID = 1L;
         private FullScreenDisplay display;
         public static void main(String args[])
              Thread t = new Thread(new Runner());
              t.start();
         public Runner()
              makeGui();
         private void makeGui()
              display = new FullScreenDisplay(this);
         public void run()
              try {
                   Thread.sleep(1000);
              } catch (InterruptedException e) {/*Nothing to do*/}
              run();
         public void quit()
              System.exit(0);
    package gui;
    import game.Runner;
    import java.awt.GraphicsEnvironment;
    import java.awt.event.KeyEvent;
    import javax.swing.KeyStroke;
    import javax.swing.AbstractAction;
    import java.awt.event.ActionEvent;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import java.awt.Graphics;
    import java.awt.Image;
    import javax.imageio.ImageIO;
    import java.io.File;
    import java.io.IOException;
    public class FullScreenDisplay extends JFrame {
         private static final long serialVersionUID = 1L;
         private Runner master;
         private JPanel mainPanel;
         private Image tempImage;
         public FullScreenDisplay(Runner master)
              super();
              //Remove this eventually.
              try {
                   tempImage = ImageIO.read(new File("test_image.jpg"));
              } catch (IOException e) {
                   System.out.println("image get error");
                   e.printStackTrace();
              this.master = master;
              makeFrame();
              makePanel();
              makeKeyBindings();
              //setFullScreen(chooseBufferStrategy());
              setFullScreen();
              requestFocus();
              setVisible(true);
              //Remove this eventually.
              Graphics g = tempImage.getGraphics();
              mainPanel.paint(g);
              this.update(g);
         private void makeFrame()
              setUndecorated(true);
              setResizable(false);
              setFocusable(true);
         private void makePanel()
              mainPanel = new JPanel(){
                   public void paintComponent(Graphics g) {
                        if(tempImage == null){
                             System.out.println("Balls");
                        g.drawRect(10, 10, 10, 10);
                        g.drawImage(tempImage,0,0,null);
                        super.paintComponent(g);
                        System.out.println("Did it work");
              add(mainPanel);
         private void makeKeyBindings()
              mainPanel.setFocusable(true);
              //Key bindings... don't like using a string to index, find out if there's a better way.
              mainPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "exit");
              mainPanel.getActionMap().put("exit", new AbstractAction(){
                   public void actionPerformed(ActionEvent e)
                        master.quit();
         /*private void chooseBufferSrategy()
         private void setFullScreen()
              GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(this);
    }

    super.paintComponent(g);should be the first line in paintComponent()
    also, you don't really need the keyBindings to quit,
    just set the default close to exit and Alt-F4 will close/quit

  • How to display right-click menu for JPanel?

    Hi...
    I am developing an application to display a JWindow in the screen along with a TrayIcon in the system-tray area. There should be a right-click menu in both the tray icon and JWindow for further options.
    I am able to create a JPopupMenu for tray icon. On right-clicking on the tray icon, the menu is being displayed. But not able to do the same for the JWindow. I am able to capture the right-click mouse event, but not able to display the menu.
    This is how I am displaying the menu for the tray icon
    PopupMenu  popupmenu = new PopupMenu();
    MenuItem  menuitem1 = new MenuItem("Exit");
    menuitem1.addActionListener(new ActionListener()
        public void actionPerformed(ActionEvent exx)
            System.exit(0);
    popupmenu.add(menuitem1);
    trayicon = new TrayIcon(Toolkit.getDefaultToolkit().getImage("./images/Icon.gif"),"Right-click for more options",popupmenu);For displaying the menu in the JPanel, I am using the following snippet...
        public class MyMouseListener extends MouseAdapter
            public class MyMouseListener() {}
            @Override
            public void mouseClicked(MouseEvent e)
                if (e.getButton() == MouseEvent.BUTTON3)
                   System.out.println("Clicked");
                   jp.setComponentPopupMenu(popupmenu);
        }Can anyone please help me to do this??
    Thanks in Advance...

    Hi,
    PFA the code I am using...
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class DisplayStrip extends JWindow implements MouseListener, MouseMotionListener
         Point location;
         MouseEvent pressed;
        JPanel jp ;
        JLabel jl ;
        JPopupMenu popupmenu ;
         public DisplayStrip()
              addMouseListener( this );
              addMouseMotionListener( this );
         public void mousePressed(MouseEvent me)
              pressed = me;
         public void mouseClicked(MouseEvent e) {}
         public void mouseReleased(MouseEvent e) {}
         public void mouseDragged(MouseEvent me)
              location = getLocation(location);
              int x = location.x - pressed.getX() + me.getX();
              int y = location.y - pressed.getY() + me.getY();
              setLocation(x, y);
         public void mouseMoved(MouseEvent e) {}
         public void mouseEntered(MouseEvent e) {}
         public void mouseExited(MouseEvent e) {}
         public void DisplayStripRun()
              setSize(100, 10);
              setAlwaysOnTop(true);
            jp = new JPanel();
              jp.setBackground(Color.GREEN);
              jp.addMouseListener(new MyMouseListener());
              jl = new JLabel();
              jl.setText("Right-click Here");
              jp.add(jl);
              add(jp);
              setVisible(true);
              pack();
              popupmenu = new JPopupMenu();
              JMenuItem menuitem = new JMenuItem("Exit");
              menuitem.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent exx)
                        System.exit(0);
              popupmenu.add(menuitem);
         public static void main(String args[])
              DisplayStrip ds = new DisplayStrip();
              ds.DisplayStripRun();
        public class MyMouseListener extends MouseAdapter
            //public class MyMouseListener() {}
            @Override
            public void mouseClicked(MouseEvent e)
                if (e.getButton() == MouseEvent.BUTTON3)
                   System.out.println("Right clicked");
                   jp.setComponentPopupMenu(popupmenu);
                   popupmenu.setVisible(true);
    }

  • Copying image to jpanel

    when i copy an image to jpanel using jlabel i.e
    jlabel lab = new jlabel(new Iconimage("xyz.jpg"));
    i cannot listen to any keys being pressed on the label when i want to copy the image onto a clip board( cntrl C). Is there any method of listening to keys being pressed on jlabel or a method to display the image on jpanel which listens to keys.

    can give code to draw image on Panel.
    icon = new ImageIcon("backUp.gif");
    JPanel panel = new JPanel()
         protected void paintComponent(Graphics g)
              g.drawImage(icon.getImage(), 0, 0, null);
              super.paintComponent(g);
    panel.setOpaque( false );

Maybe you are looking for

  • Bluetooth no longer pairs with Acura TSX

    I have had an Acura TSX since September 2012.  The bluetooth on my iphone paired fine, and continued to work okay after I got the iphone 5 in October.  However, a few months or so ago, it randomly "unpaired" from the phone.  I was able to "forget the

  • New 21.5 iMac for Adobe Suite CS4?

    I am interested in the new Apple _iMac 21.5_ model with the _GPU 9400_ of nVidia (basic model). I want to know if the processor and the GPU are sufficient to work correctly with Photoshop CS4, Illustrator CS4, Flash CS4, Dreamweaver CS4, etc. Is this

  • ORA-02303 when creating database on Exadata using template with BP12

    I get ORA-02303 when creating a RAC database on Exadata. Logs indicate that error happened when applying bundle patch BP12 and probably when running following script: /u01/app/oracle/product/11.2.0.4/dbhome_1/rdbms/admin/catsnap.sql CREATE OR REPLACE

  • File is appending instead of overwrite.

    Hi We have a file interface with overwrite settings. When tested from ECC the file is being overwritten as per the settings. When retested the same, the file is being appending data. The same is also tested from another Quality system and there also

  • HT201232 I m fron india where can i contact apple technical team support ?

    I m from India where can i contact apple technical support team ?