Adding bitmap or gif image in dashboad

Hi experts,
I want to add one bitmap image in my xcelsius dashboad?
How can i do this?
Thanks in advance,
Rishit

Hi guys,
I got soln by adding image component in my dashboad.
Sorry for this trouble.
Thanks,
Rishit

Similar Messages

  • Adding GIF images to a stand-alone program

    To add a GIF image to an applet one can use the "getImage" function defined in the applet class.
    How do i add an image to a stand-alone program in java when one doesn't extend the Applet class ( and so one doesn't have access
    to the "getImage" procedure)
    I have just begun with Java so please reply in simple english and not in some hard-to-understand "Javian" crap!
    Thank u

    You mean a JFrame?
    import java.awt.*;
    import javax.swing.*;
    public class JFrameImage extends JFrame {
      public JFrameImage() {
          Container c    = getContentPane();
          JPanel panel = new JPanel(){
                 public void paintComponent(Graphics g)     {
    // puts an image on the whole program as background
                      ImageIcon img = new ImageIcon("myBackground.jpg");
                      g.drawImage(img.getImage(), 0, 0, null);
                      super.paintComponent(g);
            panel.setOpaque(false);
    // puts an image on the button
          ImageIcon icon = new ImageIcon("myButton.jpg");
          JButton button = new JButton(icon);
          panel.add(button);
          c.add(panel);
      public static void main(String[] args) {
        JFrameImage frame = new JFrameImage();
    // puts your own personal image on the frame itself
          Image onFrame = Toolkit.getDefaultToolkit().getImage("myIcon.gif") ;
        frame.setIconImage(onFrame);
        frame.setSize(200,200);
    // stops the thing looking sh*tty and amateurish by putting it nearer the middle
    // of the screen, instead of the default top left hand corner
        frame.setLocation(300,200);
        frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
        frame.setVisible(true);
    }

  • Adding a gif image

    At the moment I have just drawn checkers but I would like to add a .gif image so it looks alot better. But im really unsure how to do this without completely messing things up. Thanks to any help guys
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MyDraughts1edited extends Applet
                             implements MouseListener, MouseMotionListener{
      private int top = 0, left1 = 0, bWidth = 200, n = 4;
      private Point counter1, counter2, counter3, counter4, counter5, counter6,
       counter7, counter8, mouse;
      private int select;
      public void init() {
        this.addMouseMotionListener(this);
        this.addMouseListener(this);
        counter1 = new Point(15,15);
        counter2 = new Point(65,15);
        counter3 = new Point(115,15);
        counter4 = new Point(165,15);
        counter5 = new Point(15,165);
        counter6 = new Point(65,165);
        counter7 = new Point(115,165);
        counter8 = new Point(165,165);
      public void paint (Graphics g) {
        Draw_Board(g);
        g.setColor (Color.black);
        g.fillOval(counter1.x, counter1.y, 20,20);
        g.fillOval(counter2.x, counter2.y, 20,20);
        g.fillOval(counter3.x, counter3.y, 20,20);
        g.fillOval(counter4.x, counter4.y, 20,20);
        g.setColor (Color.white);
        g.fillOval(counter5.x, counter5.y, 20,20);
        g.fillOval(counter6.x, counter6.y, 20,20);
        g.fillOval(counter7.x, counter7.y, 20,20);
        g.fillOval(counter8.x, counter8.y, 20,20);
      public void mouseDragged(MouseEvent e) {
        mouse = e.getPoint();
        // continuously change the coordinates of the selected counter
        switch(select){
          case 1 : counter1 = mouse; break;
          case 2 : counter2 = mouse; break;
          case 3 : counter3 = mouse; break;
          case 4 : counter4 = mouse; break;
          case 5 : counter5 = mouse; break;
          case 6 : counter6 = mouse; break;
          case 7 : counter7 = mouse; break;
          case 8 : counter8 = mouse; break;
          default :
        repaint();
      // required for the interface
      public void mouseMoved(MouseEvent e) {}
      public void mousePressed(MouseEvent e) {
        mouse = e.getPoint();
        if (mouse.x > counter1.x - 20 && mouse.x < counter1.x + 20 &&
            mouse.y > counter1.y - 20 && mouse.y < counter1.y + 20){
          select = 1;
        else if (mouse.x > counter2.x - 20 && mouse.x < counter2.x + 20 &&
            mouse.y > counter2.y - 20 && mouse.y < counter2.y + 20){
          select = 2;
        else if (mouse.x > counter3.x - 20 && mouse.x < counter3.x + 20 &&
            mouse.y > counter3.y - 20 && mouse.y < counter3.y + 20){
          select = 3;
        else if (mouse.x > counter4.x - 20 && mouse.x < counter4.x + 20 &&
            mouse.y > counter4.y - 20 && mouse.y < counter4.y + 20){
          select = 4;
        else if (mouse.x > counter5.x - 20 && mouse.x < counter5.x + 20 &&
            mouse.y > counter5.y - 20 && mouse.y < counter5.y + 20){
          select = 5;
        else if (mouse.x > counter6.x - 20 && mouse.x < counter6.x + 20 &&
            mouse.y > counter6.y - 20 && mouse.y < counter6.y + 20){
          select = 6;
        else if (mouse.x > counter7.x - 20 && mouse.x < counter7.x + 20 &&
            mouse.y > counter7.y - 20 && mouse.y < counter7.y + 20){
          select = 7;
        else if (mouse.x > counter8.x - 20 && mouse.x < counter8.x + 20 &&
            mouse.y > counter8.y - 20 && mouse.y < counter8.y + 20){
          select = 8;
        else{
        repaint();
      // required for the interface
      public void mouseClicked(MouseEvent event){}
      public void mouseReleased(MouseEvent event){}
      public void mouseEntered(MouseEvent event){}
      public void mouseExited(MouseEvent event){}
      private void Draw_Board(Graphics g) {
        int sqWidth = bWidth/n; // Rounds down
        for (int row = 0; row < 4; ++row){
          for(int Col=0; Col<4; Col++) {
            g.setColor(posColor(row, Col));
            g.fillRect
             (left1 + Col * sqWidth, top + row * sqWidth, sqWidth, sqWidth);
      private boolean isEven(int x) {
        return(x == 2 * (x / 2));
      private Color posColor(int row, int Col) {
        if ( (isEven(row) && isEven(Col)) ||
            (! isEven(row) && ! isEven(Col))){
          return(Color.GRAY);
        else{
          return(Color.lightGray);
    }

    If you can use Swing instead of AWT, then maybe this posting will give you some ideas:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=518707&start=3

  • How to use new icons (gif images)  added to the icons folder in forms 6i???

    Hi all,
    I have added some new icons images to the path:
    \\FORMS60\java\oracle\forms\icons
    Now how to show this icons on buttons at run time?

    You mentioned your directory path as \\FORMS60\java\oracle\forms\icons, is this a local directory??? If it's a network directory make sure the directory is accesible by the user.
    Try to create a local directory like C:\my_icons and put your icons in it make sure the directory you have your icons in it is listed in FORMS_PATH registry key string.
    And make sure you icons are of .ico format.
    Tony

  • Animated Gif Image does not render correctly on screen

    I have added animated gif image to the scene it does not render correctely.it shakes on the screen. plz give me any suggestion
    i use following code
    Image logo= new Image(getClass().getResourceAsStream("images/image.gif"));
    logoLabel.setGraphic(new ImageView(logo));

    Hello user,
    I think gif are rendered smoothly.
    Are you sure you are not making many object of same images everytime?
    Thanks.
    Narayan

  • Using GIF images in iMovie11 ??

    Admittedly this is now my first attempt at using the iMovie8/9/11 editing structure since I was perfectly satisfied with iMovie06 HD and that timeline approach. In the old program I had GIF formatted images (Maps) that I had available in my "Photos" Media for adding to my Project timeline in the same fashion I would use a still JPG photo.
    After a number of hours searching the forum here and all the iMovie 9/11 documentation I can find, it appears  this new version of iMovie does not display GIF images in your iPhoto Media list to use for projects. Bottomline is I am not able to drag a gif map into my video project. It seems only JPG format files are now displayed in iMovie's iPHOTO Media source list.  I have one graphic that is a collage of photos and graphical objects which I had saved in JPG format to preserve the photo quality and that one shows in my Media list. No GIFs.  What gives?  I can open iPhoto stand alone and see my map graphics that are present in the database in their own Rolls.  I've tried dragging, dropping, importing, etc. with no success.
    This is a significant limitation (or bug) if the current version of iMovie does not allow free use of graphical images in GIF format. Can anyone shed some light on this and help solve my problem before I go back to iMovie HD?  Thanks in advance.

    Klondike Kid wrote:
    Hmm, doesn't seem to make sense …
    I'm not in the position here to 'defend' Apples decision, but an expert as you should keep in mind:
    iM vers.≤6 was a completely diff app than iM vers. ≥08
    same name, from the ground different programs (not only on the outside)
    video isn't based upon limited 256 colors, nor has inserting a file-size-degraded still any effect on the resulting video-file size.
    Photoshop is a >1k$ professional tool, meant for stills - so, it should support a bunch of formats, including obsolete ones. iMovie is a 15$ consumer toy tool, by concept reduced in options to offer convenience - for a broad range of people - I dare to say, the majority of iMovie users dont even know the existence of 'gif', iMovies iLife partner for stills, iPhoto, is biased to jpg.-
    Klondike Kid wrote:
    … I guess I'll have to live without it for iMovie.
    on MacOS, there's little options, I haven't tried, but I wouldn't be surprised, if FCPX doesn't support gif either. pretty sure, Premiere as part of the Adobe CS suite, will handle it - somehow.
    happy movie making!

  • Gif images for iconic button?anybody met success

    I have done everything what is specified in the doc i.e added the lineof code for app.iconpath and referred the same in the HTML FOR cartridge in serverApp param
    and also in the cartridge parameters but the result no the buttons just stare balank at me.
    Instead i tried to replace the buttons with the 1k,2k size gif images oops! Oracle Developer server can't even take a byte of
    image files and the application hangs searching for the file.
    Why can anyone who has met with success please tell me how?
    Mahesh

    I tryed almost everuthing (I'm using WebDB
    listener not OAS)
    The only sollution worked for me is
    in Registry.dat (NOT WINDOWS REGISTRY)
    which located in
    ORACLE_HOME\FORMS60\JAVA\ORACLE\FORMS\REGISTRY
    FOLLOWING SETTINGS
    default.icons.iconpath=/dev60temp/
    default.icons.iconextension=gif
    where /dev60temp/ is virtual directory made
    for WebDB listener.
    Please let me know if your immage looks Ok.
    Mine is shifted to the upper right corner.
    Good luck!

  • Problem in displaying  gif image on to the JFrame

    i added gif image in to the jframe but when i run that image the image get distorted very much.

    public class MyFrame extends JFrame
         private static final String sIMAGE_PATH = "My\\Path\\To\\Image\\fileName.gif";
         public MyFrame()
              super("Frame with image on it");
              init();
         private void init()
              JPanel panel = new JPanel(new BorderLayout());
              ImageIcon image = new ImageIcon(sIMAGE_PATH);
              JLabel label = new JLabel(image);
              panel.add(label, BorderLayout.CENTER);
              this.setContentPane(panel);
         }Hope this helps..

  • Adding JTable on an image..............??help need.....edited

    i am using JFame
    on JFrame i hav added JTabbedpane....
    on one of the tab i hav added image on whole background....
    on that tab i hav added JTable....
    but when i add JTable on that tab .....instead of adding table on that image...it add image on background with no image
    that no color part shoud be covered with part of image added on a tab
    and also i want to position (x,y) of JTable on tab.....
    so i hav used gridLayout so that it looks better....but that not i want.....
    here is the code.... check search tab
    //project.java
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    class tdsgui{
    JFrame f,pass;
    JTabbedPane jtp = new JTabbedPane();
    JApplet obj=new JApplet();
    JMenuBar mb=new JMenuBar();
    public tdsgui(){
    f=new JFrame("TELEPHONE DIRECTORY SYSTEM");
    JMenu m1=new JMenu("File");
    JMenu m2=new JMenu("About");
    JMenu m3=new JMenu("Help");
    mb.add(m1);
    mb.add(m2);
    mb.add(m3);
    JMenuItem mi1=new JMenuItem("Save");
    JMenuItem mi2=new JMenuItem("Exit");
    JMenuItem mi3=new JMenuItem("save as");
    mi3.setVisible(true);
    m1.add(mi1);
    m1.add(mi3);
    m1.add(mi2);
    public void launch(){
    jtp.addTab(" REGISTRATION ",new registerpanel());
    jtp.addTab(" MODIFY ",new updatepanel());
    jtp.addTab(" SEARCH ", new searchpanel());
    f.add(mb);
    f.setJMenuBar(mb);
    f.add(jtp);
    f.setSize(500,600);
    f.setVisible(true);
    public class project{
    public static void main(String args[]){
    tdsgui next=new tdsgui();
    next.launch();
    class registerpanel extends JPanel{
    public registerpanel(){
    class updatepanel extends JPanel{
    public updatepanel(){
    class searchpanel extends JPanel{
    public searchpanel(){
    Icon icon = new ImageIcon("Sunset.jpg");
    JLabel label = new JLabel(icon);
    add(label);
    this.setLayout(new GridLayout(2,0));
    final String[] colHeads = { "Name", "Phone", "Fax" };
    final String[][] data = {
    { "Gail", "4567", "8675" },
    { "Ken", "7566", "5555" },
    { "Viviane", "5634", "5887" },
    { "Melanie", "7345", "9222" },
    { "Anne", "1237", "3333" },
    { "John", "5656", "3144" }
    // Create the table
    JTable table = new JTable(data, colHeads);
    JTableHeader header = table.getTableHeader();
    table.setRowHeight(20);
    TableColumn column = table.getColumnModel().getColumn(0);
    table.setCellSelectionEnabled(true);
    table.getTableHeader().setPreferredSize(new Dimension(0,30));
    table.setFont(new Font("Dialog", Font.BOLD, 15));
    table.setBackground(Color.green);
    header.setFont(new Font("Courier",Font.BOLD,25));
    header.setBackground(Color.yellow);
    //label.add(table,BorderLayout.CENTER);
    // Add table to a scroll pane
    int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
    int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
    JScrollPane jsp = new JScrollPane(table, v, h);
    // Add scroll pane to the content pane
    this.add(jsp, BorderLayout.SOUTH);
    add image i ur system....make changes on searchpanel class
    thanks in advance...

    on one of the tab i hav added image on whole background....no you haven't - you've added a JLabel to a GridLayout JPanel
    I have no idea what you're really trying to do, but here's a tab with image background and transparent table (except for the header)
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    class tdsgui{
    JFrame f;
    JTabbedPane jtp = new JTabbedPane();
    public tdsgui(){
    f=new JFrame("TELEPHONE DIRECTORY SYSTEM");
    public void launch(){
    jtp.addTab(" REGISTRATION ",new registerpanel());
    jtp.addTab(" MODIFY ",new updatepanel());
    jtp.addTab(" SEARCH ", new searchpanel());
    f.add(jtp);
    f.setSize(500,600);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
    class project{
    public static void main(String args[]){
    tdsgui next=new tdsgui();
    next.launch();
    class registerpanel extends JPanel{
    public registerpanel(){
    class updatepanel extends JPanel{
    public updatepanel(){
    class searchpanel extends JPanel{
    Image img;
    public searchpanel(){
    try{img = javax.imageio.ImageIO.read(new java.net.URL(getClass().getResource("Test.gif"), "Test.gif"));}
    catch(Exception e){}//do nothing - handled in paintComponent
    this.setLayout(new GridLayout(2,0));
    final String[] colHeads = { "Name", "Phone", "Fax" };
    final String[][] data = {
    { "Gail", "4567", "8675" },
    { "Ken", "7566", "5555" },
    { "Viviane", "5634", "5887" },
    { "Melanie", "7345", "9222" },
    { "Anne", "1237", "3333" },
    { "John", "5656", "3144" }
    JTable table = new JTable(data, colHeads);
    table.setOpaque(false);
    table.setBackground(new Color(0,0,0,0));
    JScrollPane jsp = new JScrollPane(table);
    jsp.setOpaque(false);
    jsp.getViewport().setOpaque(false);
    this.add(jsp);
    public void paintComponent(Graphics g){
    super.paintComponent(g);
    if(img != null) g.drawImage(img,0,0,this.getWidth(), this.getHeight(),this);
    }

  • Import and Display GIF images

    Hi,
    I'm trying to manage images in Abap program.
    Reading on this forum, I'm able to import BMP e TIFF files (via SE78) and display them into a customer control.
    Now I'm trying to manage also GIF images.
    I'm using tc SMW0 to import gif images but with no result.
    This is what I done:
    1. call SMW0
    2. select BINARY DATA
    3. Run (no parameters specified)
    4. New button
    5. Import the GIF file.
    The system display the "No MIME type assigned to object D:\logo.gif" and no images is added.
    What I have to do?
    Thanks
    Salvatore

    Hi Salvatore,
      To display the images in Container you need to
      maintain tem in Business documnets.
      Follow the below steps :
    1) Goto tcode OAER.
    2) Give class name, as type 'OT' and Key name.
    3) Execute it and here you create document and select
       screen in the Document types then upload the bmp or
       gif file and save it.
    4) After that use this in when displaying in Container.
    Thanks&Regards,
    Siri.
    Kindly award points if it is useful.
    Message was edited by: Srilatha T

  • Error while loading a logo .gif image to the banner

    Hi all,
    I'm running Portalea on NT platform and I receive the following error, trying to load a gif image as a logo to the banner (this is in spanish but I hope you can understand it):
    Wed, 27 Dec 2000 07:03:25 GMT
    ORA-06510: PL/SQL: excepcisn definida por el usuario no tratada
    ORA-06512: en "PORTAL30.WWDOC_DOCU_BRI_TRG", lmnea 60
    ORA-06510: PL/SQL: excepcisn definida por el usuario no tratada
    ORA-04088: error durante la ejecucisn del disparador 'PORTAL30.WWDOC_DOCU_BRI_TRG'
    DAD name: portal30
    PROCEDURE : PORTAL30.wwptl_banner.savecustom
    URL : http://ORACLE1:80/pls/portal30/PORTAL30.wwptl_banner.savecustom
    PARAMETERS :
    ===========
    ENVIRONMENT:
    ============
    PLSQL_GATEWAY=WebDb
    GATEWAY_IVERSION=2
    SERVER_SOFTWARE=Apache/1.3.12 (Win32) ApacheJServ/1.1 mod_ssl/2.6.4 OpenSSL/0.9.5a mod_perl/1.22
    GATEWAY_INTERFACE=CGI/1.1
    SERVER_PORT=80
    SERVER_NAME=ORACLE1
    REQUEST_METHOD=POST
    QUERY_STRING=
    PATH_INFO=/pls/portal30/PORTAL30.wwptl_banner.savecustom
    SCRIPT_NAME=/pls
    REMOTE_HOST=
    REMOTE_ADDR=192.168.100.224
    SERVER_PROTOCOL=HTTP/1.1
    REQUEST_PROTOCOL=HTTP
    REMOTE_USER=
    HTTP_CONTENT_LENGTH=6443
    HTTP_CONTENT_TYPE=multipart/form-data; boundary=---------------------------7d02753210f0280
    HTTP_USER_AGENT=Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)
    HTTP_HOST=oracle1
    HTTP_ACCEPT=application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-comet, */*
    HTTP_ACCEPT_ENCODING=gzip, deflate
    HTTP_ACCEPT_LANGUAGE=es
    HTTP_ACCEPT_CHARSET=
    HTTP_COOKIE=portal30=AB515A5F55262E576590647AC04D98A8EF1D5A6F56D19ECCD710BDB4A08D2354903C0CA288FDE0C9283E116C71C00B1B3821CEAB7A24979CFF326F4979143EE1FD147BC097C2AD7705313C93DAB32D8 4A6CF71C26B267CC0B2FEA03B385A2E84; portal30_sso=7452540140821A6010973F5CAC7E7D17C7498F309E15C228015C1C0546A702F5AFDE500B69BDCB8DE5C29DD726FC8DEEE85A1DC979ECC7B8A6A16CADEF1DAB0C0ACEC11897D5B99B1033884D61307BEA7AE581C 8AB988C8CBBBDCE6174BA01F6
    Authorization=
    HTTP_IF_MODIFIED_SINCE=
    null

    Hi,
    No errors was found in the installation log. I'm looking in the WWDOC_DOCUMENT$ table and found records that make references to my previous tries to upload the logo image. In order to make others tries, how can I delete this information? Are references to this files in any other table?.
    I'm looking over the solution provide by Laurent Baresse, refering to the NLS_LANGUAJE problem ... (Thanks Laurent).
    Best regards
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Karthika Siva ([email protected]):
    Fernando,
    Are you able to upload any documents into a content area? Please look at your installation log file (install.log) for any errors that may have occured during the installation of the product. Also make sure that the tablespace containing the WWDOC_DOCUMENT$ table is not full.
    Karthika<HR></BLOCKQUOTE>
    null

  • Animated gif image

    Hi
    I like to create an animated gif image from a given set of images with java. I like to do this with the given set of java api as I do not want to use a commercial graphics library. Can anyone provide me with a sample example.
    Thanks

    Hi
    I like to resize a gif image. Currently i am using the following code but the resized image is not smooth.
    public BufferedImage resizeImage(BufferedImage img, int newW, int newH)
              int w = img.getWidth();
              int h = img.getHeight();
              BufferedImage dimg = new BufferedImage(newW, newH, img.getType());
              Graphics2D g = dimg.createGraphics();
              g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
              g.drawImage(img, 0, 0, newW, newH, 0, 0, w, h, null);
              g.dispose();
              return dimg;
    Is there a way to resize a gif image in a smooth way as the example given in the gif4j library
    Thanks

  • Animated GIF image gets distorted while playing.

    Hi,
    I have some animated gif images which I need to show in a jLabel and a jTextPane. But some of these images are getting distorted while playing in the two components, though these images are playing properly in Internet Explorer. I am using the methods insertIcon() of jTextPane and setIcon() of jLabel to add or set the gif images in the two components. Can you please suggest any suitable idea of how I can get rid of this distortion? Thanks in advance.

    In the code below is a self contained JComponent that paints a series of BufferedImages as an animation. You can pause the animation, and you specify the delay. It also has two static methods for loading all the frames from a File or a URL.
    Feel free to add functionality to it, like the ability to display text or manipulate the animation. You may wan't the class to extend JLabel instead of JComponent. Just explore around with the painting. If you have any questions, then feel free to post.
    The downside to working with an array of BufferedImages, though, is that they consume more memory then a single Toolkit gif image.
    import javax.swing.JComponent;
    import java.awt.image.BufferedImage;
    import java.awt.Graphics;
    import javax.imageio.ImageIO;
    import javax.imageio.ImageReader;
    import javax.imageio.stream.ImageInputStream;
    public class JAnimationLabel extends JComponent {
        /**The default animation delay.  100 milliseconds*/
        public static final int DEFAULT_DELAY = 100;
        private BufferedImage[] images;
        private int currentIndex;
        private int delay;
        private boolean paused;
        private boolean exited;
        private final Object lock = new Object();
        //the maximum image width and height in the image array
        private int maxWidth;
        private int maxHeight;
        public JAnimationLabel(BufferedImage[] animation) {
            if(animation == null)
                throw new NullPointerException("null animation!");
            for(BufferedImage frame : animation)
                if(frame == null)
                    throw new NullPointerException("null frame in animation!");
            images = animation;
            delay = DEFAULT_DELAY;
            paused = false;
            for(BufferedImage frame : animation) {
                maxWidth = Math.max(maxWidth,frame.getWidth());
                maxHeight = Math.max(maxHeight,frame.getHeight());
            setPreferredSize(new java.awt.Dimension(maxWidth,maxHeight));
        //This method is called when a component is connected to a native
        //resource.  It is an indication that we can now start painting.
        public void addNotify() {
            super.addNotify();
            //Make anonymous thread run animation loop.  Alternative
            //would be to make the AnimationLabel class extend Runnable,
            //but this would allow innapropriate use.
            exited = false;
            Thread runner = new Thread(new Runnable() {
                public void run() {
                    runAnimation();
            runner.setDaemon(true);
            runner.start();
        public void removeNotify() {
            exited = true;
            super.removeNotify();
        /**Returns the animation delay in milliseconds.*/
        public int getDelay() {return delay;}
        /**Sets the animation delay between two
         * consecutive frames in milliseconds.*/
        public void setDelay(int delay) {this.delay = delay;}
        /**Returns whether the animation is currently paused.*/
        public boolean isPaused() {
            return exited?true:paused;}
        /**Makes the animation paused or resumes the painting.*/
        public void setPaused(boolean paused) {
            synchronized(lock) {
                this.paused = paused;
                lock.notify();
        private void runAnimation() {
            while(!exited) {
                repaint();
                if(delay > 0) {
                    try{Thread.sleep(delay);}
                    catch(InterruptedException e) {
                        System.err.println("Animation Sleep interupted");
                synchronized(lock) {
                    while(paused) {
                        try{lock.wait();}
                        catch(InterruptedException e) {}
        public void paintComponent(Graphics g) {
            if(g == null) return;
            java.awt.Rectangle bounds = g.getClipBounds();
            //center image on label
            int x = (getWidth()-maxWidth)/2;
            int y = (getHeight()-maxHeight)/2;
            g.drawImage(images[currentIndex], x, y,this);
            if(bounds.x == 0 && bounds.y == 0 &&
               bounds.width == getWidth() && bounds.height == getHeight()) {
                 //increment frame for the next time around if the bounds on
                 //the graphics object represents a full repaint
                 currentIndex = (currentIndex+1)%images.length;
            }else {
                //if partial repaint then we do not need to
                //increment to the the next frame
    }

  • Digital watermarking gif images

    I ve writed a program which watermarks png and non-animated gif images .But there is a problem because we started to use animated gif images. How can we watermark animated gif images without corrupting animation of the image?
    Regards
    Murat

    I haven't done much with gif animation, but here's an example that extracts the series of BufferedImages
    from a gif file. Good luck!
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.io.*;
    import java.net.*;
    import java.net.URL;
    import java.util.*;
    import javax.imageio.*;
    import javax.imageio.metadata.*;
    import javax.imageio.stream.*;
    import javax.swing.*;
    import org.w3c.dom.*;
    public class ViewGif extends JPanel {
        private BufferedImage[] images;
        private Point[] offsets;
        private BufferedImage composite;
        public static void main(String[] args) throws IOException {
            JPanel app = new ViewGif();
            app.setBackground(Color.RED);
            JFrame frame = new JFrame("ViewGif");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.getContentPane().add(new JScrollPane(app));
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        public ViewGif() throws IOException {
            URL url = new URL("http://members.aol.com/royalef/sunglass.gif");
            Iterator readers = ImageIO.getImageReadersBySuffix("gif");
            if (!readers.hasNext())
                throw new IOException("no gif readers");
            ImageReader reader = (ImageReader) readers.next();
            if (readers.hasNext())
                System.out.println("(there were oither readers)");
            ImageInputStream iis = ImageIO.createImageInputStream(url.openStream());
            reader.setInput(iis);
            final int numImages = reader.getNumImages(true);
            images = new BufferedImage[numImages];
            offsets = new Point[numImages];
            for(int i=0; i<numImages; ++i) {
                images[i] =  reader.read(i);
                offsets[i] = getPixelOffsets(reader, i);
            composite = new BufferedImage(images[0].getWidth(), images[0].getHeight(),
                BufferedImage.TYPE_INT_ARGB);
            final Graphics2D g2 = composite.createGraphics();
            g2.drawImage(images[0], offsets[0].x, offsets[0].y, null);
            new javax.swing.Timer(100, new ActionListener(){
                int j = 1;
                public void actionPerformed(ActionEvent evt) {
                    g2.drawImage(images[j], offsets[j].x, offsets[j].y, null);
                    j = (j+1) % numImages;
                    repaint();
            }).start();
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Insets insets = getInsets();
            g.drawImage(composite, insets.left, insets.top, null);
        public Dimension getPreferredSize() {
            Insets insets = getInsets();
            int w = insets.left + insets.right + composite.getWidth();
            int h = insets.top + insets.bottom + composite.getHeight();
            return new Dimension(w,h);
        static Point getPixelOffsets(ImageReader reader, int num) throws IOException {
            IIOMetadata meta = reader.getImageMetadata(num);
            Point point = new Point(-1,-1);
            Node root = meta.getAsTree("javax_imageio_1.0");
            for (Node c = root.getFirstChild(); c != null; c = c.getNextSibling()) {
                String name = c.getNodeName();
                if ("Dimension".equals(name)) {
                    for (c = c.getFirstChild(); c != null; c = c.getNextSibling()) {
                        name = c.getNodeName();
                        if ("HorizontalPixelOffset".equals(name))
                            point.x = getValueAttribute(c);
                        else if ("VerticalPixelOffset".equals(name))
                            point.y = getValueAttribute(c);
                    return point;
            return point;
        static int getValueAttribute(Node node) {
            try {
                return Integer.parseInt(node.getAttributes().getNamedItem("value").getNodeValue());
            } catch (NumberFormatException e) {
                return -2;

  • Problem at displaying animated gif images !!!!!!!!!!!!

    hello everyone......i am trying to display an animated gif image..............so till far i have no issues on this....
    but i face problem when :
    i have created a class called SimpleGame which extends JPanel....
    public class SimpleGame extends JPanel
    //code
    public void paintComponent(Graphics g)
    //code to draw image
    }now i have written another class with main method
    public class MyGame extends SimpleGame
    public MyGame()
            JFrame frame=new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(800, 600);
            frame.setUndecorated(true);
            frame.setLocationRelativeTo(null);
            frame.getContentPane().add(this);
            frame.setVisible(true);
            this.repaint();
    }so image gets displayed but only one frame of animated image......image that is displayed is static.....since it is a animated gif,,,,,so some how animation is not rendered......only one frame is displayed......
    why is it happening ??
    if i try to display animated image from a single class i mean my paintComponent method and main method is at same class then i do not face problem.....
    but if my paint method is in another class and i am using that method from another class then animation does not get rendered.........
    any help !!!!! please...........

    class SimpleGame extends JPanel
    Image img=new ImageIcon("y.gif");
    public void paintComponent(Graphics g)
    g.drawImage(img,150,150,this);
    }main class//
    class MyGame extends SimpleGame
    public MyGame()
            JFrame frame=new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(800, 600);
            frame.setUndecorated(true);
            frame.setLocationRelativeTo(null);
            frame.getContentPane().add(this);
            frame.setVisible(true);
            this.repaint();
    public static void main(String[] args)
    new MyGame();
    }my image gets displayed.......but only single frame of a animated image....animation is not happening..........

Maybe you are looking for