Drawing multiple .gif images

Hello, I am creating a Card class and a Deck class, and I have .gif images for each card. I am trying to create a CardDisplay class to test my images. The Card/Deck classes work fine, but I am running into problems getting the images to display. What I have is a JFrame and I use a JLabel for each .gif image. When I add the JLabel to the contentPane, it is still only showing a blank window. Can someone give me any guidance as to how to go about this? Also, I am assuming once I get it to display 1 gif, it will display the remaining 51 in the same place. What I am trying to do is to display them all in a row.. well 4 rows of 13 cards that is. Thanks in advance,
dub stylee

Also, just wanted to add that this is not for school. I am doing this for a personal exercise using swing components. I made a card game when I was taking java 1 class, but now I am trying to familiarize myself with the use of graphics. Thanks to anybody who can help.
dub stylee

Similar Messages

  • Drawing moving GIF images?

    Is it possible to draw moving gif images on a simple Frame applet?
    I made an image drawer class for my applet and i can draw simple 2d images.
    Here is the basis of my GameSprite class;
        public byte[] pixels;
        public int width;
        public int height;
        public GameSprite(String imageName, int requestIndex) {
         try {
                    // Removed code, it's zipInputStream, but it can be used just as ./image.jpg etc
         javax.swing.ImageIcon icon = new javax.swing.ImageIcon(fileBytes);
         width = icon.getIconWidth();
                     height = icon.getIconHeight();
                     pixels = fileBytes;
         } catch(Exception e) {
              e.printStackTrace();
        public void drawSprite(int x, int y) {
         try {
              Image image = Toolkit.getDefaultToolkit().createImage(pixels);
                                    //Removed code here
              graphics.drawImage(image, x, y + 7, width, height, observer);
         } catch(Exception e) {
              e.printStackTrace();
        }If i try to draw an animated gif image it dosn't move.
    Thanks for any help.

    In Java you need to override the paint method in AWT and paintComponenet method in SWING to do graphics/animation. If you go to an offscreen rendering, then you can paint to the graphics context of an image you use for a drawImage in your paint/paintComponent...
    If you where overriding a Panel in AWT you would override paint:
    public void paint(Graphics g){
      g.drawImage(im, 0, 0, this);
    }Then where you are maipulating your graphics you would do something like this:
    //code snippet
    Graphics g = im.getGraphics();
    //make what ever changes to im by manipulating the graphics context g
    repaint();

  • Drawing multiple SVG images in GTK+

    Hi,
    I am planning to at least try and write an application that would compose a document in ancient Egyptian hieroglyphs (of all things ;-)). Anyhow, this would involve composing the document by displaying several individual SVG-format images in the app's window, all arranged by the user to form a hieroglyphic script.
    My problem is how progressively compose the document by displaying the SVG images selected by the user and placed usually next to each other (as described here http://www.neferchichi.com/hieroglyphs.html ). In order to save the source of the document, I reckon I would have to save a record of what images were selected and what part of the drawable they were placed in.  It would also be necessary to give the user the ability to manipulate the document (select a glyph, move it, resize it etc).
    I would very much appreciate any hints and directions on this problem. If I succeed this might be the only hieroglyphic document editor that will display colored glyphs, and also the only native such application for Linux!
    You can see some of the hieroglyph images on my website: http://www.qsl.net/5b4az/pages/egypt.html

    Hi Henry,
    Does this discussion offer some clues? SVG Images Blurry
    Thanks,
    Preran

  • Drawing on top of a gif image.

    I need to be able to have a JPanel that holds a .gif image, have another JPanel over top of it that can be drawn upon. An example of this is placing a map on a table and laying a piece of clear plastic over top of it, then drawing on the plastic the route you want to take. Just as in this example, I want to be able to erase lines on the top image, but I can probably figure that part out OK, I just need the code to layer the drawing panel on top on the image.
    How can this be done?
    Thanks.

    Exactly what problem are you having with getting a layered pane? The Java Tutorial on this site can give you all the basics regarding setting one up.

  • Blackjack drawing multiple images problem

    Hi. Im making a blackjack game and im having some trouble drawing the images.
    The drawing is fine. But the problem is when to draw new cards. I dont know how to draw a new card without the old one dissapearing. I understand why it dissapears as the code is now, but i dont know how to fix it. Somehow i have to make each card beeing able to paint itself on the board? The filenames of the images to be drawn is fetched by the getCard() in the card class. Since blackjack doesnt use that many cards in play at the same time its possible to simply make more image variables and some if statements deciding which to paint, but that sollution isnt very nice, and i want to make more advanced cardgames after this, so if someone could help me with this it would truly be great.
    Thanks.
    Image displaying board after first new card is dealed, and third one
    http://www.wannerskog.com/newcards.jpg
    Card Class
    public class Card {
         private int value;
         private String color;
         public Card(String incolor,int invalue) {
              value = invalue;
              color = incolor;
         public String getCard() {
              return value+color;
         public int getValue() {
              return value;
    Deck
    import java.util.*;
    //Creates a deck of cards
    public class Deck {
         Card card;
         private Set deck = new HashSet();
         List deck2;
         public void createDeck() {
              for(int i=2; i<=14; i++) {
                   card = new Card("s",i);
                   deck.add(card);
              for(int i=2; i<=14; i++) {
                   card = new Card("h",i);
                   deck.add(card);
              for(int i=2; i<=14; i++) {
                   card = new Card("c",i);
                   deck.add(card);
              for(int i=2; i<=14; i++) {
                   card = new Card("d",i);
                   deck.add(card);
              deck2 = new Vector(deck);
         public void shuffleDeck() {
              Collections.shuffle(deck2);
         public List getDeck() {
              return deck2;
    Dealer Class
    import java.util.*;
    public class Deal {
         Deck deck = new Deck();
         private String card1;
         private String card2;
         public Deal() {
              deck.createDeck();
              deck.shuffleDeck();
         public void dealCards(int j) {
              deck.shuffleDeck();
              List d = (List)deck.getDeck();
              Card card;
              Iterator it = d.iterator();
              String card1 = "";
              String card2 = "";
              for(int i=1; i<=j; i++) {
                   card = (Card)it.next();
                   if(i==1) card1 = card.getCard();
                   if(i==2) card2 = card.getCard();
              this.card1 = card1;
              this.card2 = card2;
         public String getCard1() {
              return card1;
         public String getCard2() {
              return card2;
    Jpanel displaying the buttons
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class Controll extends JPanel {
         JButton deal = new JButton("Deal");
         JButton newcard = new JButton("New card");
         JButton stay = new JButton("Stay");
         JButton exit = new JButton("Exit");
         public Controll(View view) {
         final Deal d = new Deal();
         final View v = view;
              class ChoiceListener implements ActionListener
                   int i=0;
                   public void actionPerformed(ActionEvent event) {
                        if("deal".equals(event.getActionCommand()))
                             d.dealCards(2);
                             stay.setEnabled(true);
                             newcard.setEnabled(true);
                             deal.setEnabled(false);
                             v.dealCards(d.getCard1(),d.getCard2());
                             v.resetNew();
                             v.repaint();
                             i=0;
                        if("exit".equals(event.getActionCommand()))
                             System.exit(0);
                        if("newcard".equals(event.getActionCommand()))
                             if(i != 3) {
                                  d.dealCards(1);
                                  v.newCard(d.getCard1(),20);
                                  v.repaint();
                                  i++;
                             if(i == 3) {
                                  newcard.setEnabled(false);
                                  stay.setEnabled(false);
                                  deal.setEnabled(true);
                        if("stay".equals(event.getActionCommand()))
                             deal.setEnabled(true);
                             stay.setEnabled(false);
                             newcard.setEnabled(false);
              Color c = new Color(0, 0, 100);
              setPreferredSize(new Dimension(400, 40));
              setBackground(c);
              ActionListener listener = new ChoiceListener();
              deal.setActionCommand("deal");
              exit.setActionCommand("exit");
              newcard.setActionCommand("newcard");
              stay.setActionCommand("stay");
              exit.addActionListener(listener);
              deal.addActionListener(listener);
              newcard.addActionListener(listener);
              stay.addActionListener(listener);
              add(deal);
              add(newcard);
              add(stay);
              add(exit);
              stay.setEnabled(false);
              newcard.setEnabled(false);
    JPanel displaying the board with cards
    import java.awt.*;
    import javax.swing.*;
    import java.awt.image.*;
    import java.awt.event.*;
    public class View extends JPanel {
         String dealcard1;
         String dealcard2;
         String newcard;
         int i;
         private Image cardimage1 = null;
         private Image cardimage2 = null;
         private Image cardimage3 = null;
         public View() {
              Color c = new Color(0, 100, 0);
              setPreferredSize(new Dimension(400, 300));
              setBackground(c);
         public void dealCards(String incard1, String incard2) {
              dealcard1 = incard1;
              dealcard2 = incard2;
         public void newCard(String incard3,int j){
              newcard = incard3;
              i = i+j;
         public void resetNew() {
              i=0;
              newcard = "";
         public void paint(Graphics g) {
              super.paint(g);
              Toolkit kit = Toolkit.getDefaultToolkit();
              cardimage1 = kit.getImage("CardImages/"+dealcard1+".gif");
              cardimage2 = kit.getImage("CardImages/"+dealcard2+".gif");
              cardimage3 = kit.getImage("CardImages/"+newcard+".gif");
              g.drawImage(cardimage1,80,200,this);
              g.drawImage(cardimage2,100,200,this);
              g.drawImage(cardimage3,180+i,200,this);
    Main
    import javax.swing.*;
    import java.awt.*;
    public class Main
         public static void main(String[] args)
                   JFrame frame = new JFrame("card");
                   View v = new View();
                   Controll c = new Controll(v);
                   frame.getContentPane().add(v, BorderLayout.NORTH);
                   frame.getContentPane().add(c, BorderLayout.SOUTH);
                   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   frame.pack();
                   frame.show();
    }

    Actually, your app looks okay. Since you asked for some ideas I made some changes, including changing the name of some classes, variables and the image folder. I put all the files in one because I'm lazy. Score is the only class without changes. And nice images.
    Some suggestions:
    1 � try to keep the responsibilities of the View/CardTable class limited to rendering images. You only need to load an image once; continual loading makes for slow performance. If you are using j2se 1.4+ you can use the ImageIo read methods and could then load the images in the Deck class, eliminating the need to pass the images to Deck from View/CardTable (which is an ImageObserver needed for the MediaTracker).
    2 � let the classes do more of the work, eg, Deal/Dealer can add the new cards to the View/CardTable. This will simplify the event code. The ChoiceListener class could be an inner named/nested class and will be easier to follow/maintain if removed from the class constructor.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.util.*;
    import java.util.List;
    import javax.swing.*;
    public class CardGame
        public static void main(String[] args)
            JFrame frame = new JFrame("card");
            CardTable table = new CardTable();
            Controller control = new Controller(table);
            frame.getContentPane().add(table, BorderLayout.NORTH);
            frame.getContentPane().add(control, BorderLayout.SOUTH);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
    class CardTable extends JPanel {
        Image[] images;
        Image cardBack;
        private String score;
        List player, house;
        public CardTable() {
            loadImages();
            score = "0";
            player = new ArrayList();
            house = new ArrayList();
            Color c = new Color(0, 100, 0);
            setPreferredSize(new Dimension(400, 300));
            setBackground(c);
        public void setScore(int score) {
            this.score = String.valueOf(score);
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            int x = 80, y = 50;
            Card card;
            for(int j = 0; j < house.size(); j++) {
                card = (Card)house.get(j);
                if(j == 0)
                    g.drawImage(cardBack, x, y, this);
                else
                    g.drawImage(card.getImage(), x, y, this);
                x += 20;
            x = 80; y = 200;
            for(int j = 0; j < player.size(); j++)
                card = (Card)player.get(j);
                g.drawImage(card.getImage(), x, y, this);
                x += 20;
            g.setColor(Color.white);
            g.drawString("Score: " + score, 345, 15);
        public void reset() {
            player.clear();
            house.clear();
            repaint();
        public void addCard(Card card)
            player.add(card);
            repaint();
        public void addDealerCard(Card card)
            house.add(card);
            repaint();
        private void loadImages() {
            String[] suits = { "c", "h", "s", "d" };
            Toolkit toolkit = Toolkit.getDefaultToolkit();
            MediaTracker tracker = new MediaTracker(this);
            cardBack = toolkit.getImage("cards/00w.gif");
            tracker.addImage(cardBack, 0);
            images = new Image[suits.length * 13];
            int index = 0;
            for(int j = 0; j < suits.length; j++)
                for(int k = 2; k < 15; k++)
                    String fileName = "cards/" + k + suits[j] + ".gif";
                    images[index] = toolkit.getImage(fileName);
                    tracker.addImage(images[index], 0);
                    index++;
            try
                tracker.waitForAll();
            catch(InterruptedException ie)
                System.out.println("Image loading in CardTable interrupted: " +
                                    ie.getMessage());
    class Controller extends JPanel {
        CardTable table;
        Dealer d;
        JButton deal, newcard, stay, exit;
        public Controller(CardTable ct) {
            table = ct;
            d = new Dealer(table, table.images);
            Color c = new Color(0, 0, 100);
            setPreferredSize(new Dimension(400, 40));
            setBackground(c);
            deal = new JButton("Deal");
            newcard = new JButton("New card");
            stay = new JButton("Stay");
            exit = new JButton("Exit");
            deal.setActionCommand("deal");
            exit.setActionCommand("exit");
            newcard.setActionCommand("newcard");
            stay.setActionCommand("stay");
            ActionListener listener = new ChoiceListener();
            exit.addActionListener(listener);
            deal.addActionListener(listener);
            newcard.addActionListener(listener);
            stay.addActionListener(listener);
            add(deal);
            add(newcard);
            add(stay);
            add(exit);
            stay.setEnabled(false);
            newcard.setEnabled(false);
        private class ChoiceListener implements ActionListener {
            public void actionPerformed(ActionEvent event) {
                String ac = event.getActionCommand();
                if(ac.equals("deal")) {
                    d.prepareDeck();
                    table.reset();
                    d.dealCards(2);
                    d.dealDealerCards(2);
                    stay.setEnabled(true);
                    newcard.setEnabled(true);
                    deal.setEnabled(false);
                    Score s = d.getScore();
                    table.setScore(s.getScore());
                if(ac.equals("exit"))
                    System.exit(0);
                if(ac.equals("newcard"))
                    d.dealCards(1);
                    Score s = d.getScore();
                    table.setScore(s.getScore());
                    if(s.getScore() > 21) {
                        stay.setEnabled(false);
                        newcard.setEnabled(false);
                        deal.setEnabled(true);
                        s.resetScore();
                if(ac.equals("stay"))
                    deal.setEnabled(true);
                    stay.setEnabled(false);
                    newcard.setEnabled(false);
                    Score s = d.getScore();
                    table.setScore(s.getScore());
    class Dealer {
        CardTable table;
        Deck deck;
        Iterator it;
        private int score;
        private int dealerScore;
        Score s;
        public Dealer(CardTable ct, Image[] images) {
            table = ct;
            deck = new Deck(images);
            score = 0;
            dealerScore = 0;
            s = new Score();
        public void dealCards(int j) {
            Card card;
            for(int i = 0; i < j; i++) {
                card = (Card)it.next();
                table.addCard(card);
                if(card.getValue() > 10)
                    score += 10;
                else
                    score += card.getValue();
            s.setScore(score);
            score = 0;
        public void dealDealerCards(int j) {
            Card card;
            for(int i = 0; i < j; i++) {
                card = (Card)it.next();
                table.addDealerCard(card);
                if(card.getValue() > 10)
                    dealerScore += 10;
                else
                    dealerScore += card.getValue();
            s.setDealerScore(dealerScore);
            dealerScore = 0;
        public void prepareDeck() {
            deck.shuffle();
            it = deck.getCards().iterator();
        public Score getScore() {
            return s;
    class Score {
        private int score;
        public void setScore(int s) {
            score = score + s;
        public void resetScore() {
            score = 0;
        public int getScore() {
            return score;
        private int dealerScore;
        public void setDealerScore(int s) {
            dealerScore = dealerScore + s;
            System.out.println("DEALER: " + dealerScore);
        public void resetDealerScore() {
            dealerScore = 0;
        public int getDealerScore() {
            return dealerScore;
    class Deck {
        List cards;
        public Deck(Image[] images) {
            cards = new ArrayList();
            createDeck(images);
        private void createDeck(Image[] images) {
            for(int j = 0; j < images.length; j++)
                int value = j % 13 + 2;
                cards.add(new Card(images[j], value));
        public void shuffle() {
            for(int j = 0; j < 4; j++)
                Collections.shuffle(cards);
        public List getCards() {
            return cards;
    class Card {
        private Image image;
        private int value;
        public Card(Image image, int value) {
            this.image = image;
            this.value = value;
        public Image getImage() {
            return image;
        public int getValue() {
            return value;
    }

  • 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..........

  • BufferedImage doesn't draw every gif

    hi all,
    I create a buffered Image which should show 2 different gifs (not animated). my problem is that it draws only one of them. I don't think that it has to do with the gif itself because I tried the same drawing without buffering and everything could be seen.
    private BufferedImage bufferedBG;
    setBG();
    private void setBG() { 
    Image linieH = getToolkit().getImage(getClass().getResource("img/bg_linieH.gif"));
    Image linieV = getToolkit().getImage(getClass().getResource("img/bg_linieV.gif"));
    setBackground( Color.WHITE );
    bufferedBG = new BufferedImage( 676 + OFFSET_X, 578, BufferedImage.TYPE_INT_ARGB );
    Graphics2D g = bufferedBG.createGraphics();
    g.drawImage(linieH, 100,200, this);
    g.drawImage(linieV, 150,300, this);
    public void paint( Graphics g ) {
    Graphics2D g2 = (Graphics2D) g;
    g2.drawImage( bufferedBG, null, 0, 0 );
    any ideas?
    thanks
    gammloop

    I strongly suspect that what we have here may be confusion about user space and device space..
    The Graphics2D instance in your image class DOES NOT share coords with your paint(Graphics g)
    instance! Its x, y start is 0, 0 and bears no relation to the position on-screen of the component you are
    trying to paint...

  • Links in JPG & GIF images.

    Hello board,
    I'm making some JPGs & animated GIFs for my website, and my CMS allows images to link to only a single link; e.g. it
    links the whole image.  Is it possible to embed multiple links in a single image THEN upload to one's CMS?  If so, how?

    Marian Driscoll wrote:
    JPG and GIF image files cannot contain even a single link. Links are only made through HTML.
    You can slice the image (see Photoshop help on 'slicing') and then apply unique links to each slice in the CMS' WYSIWYG editor.
    You can also manually enter a HTML image map for a single image file if your CMS allows raw HTML and does not filter that type of input.
    Or you can use Dreamweaver.

  • Big gif files x multiple gifs files

    Hi,
    I have a question about performance:
    Is it better to have a big gif file with all tiles, sprites, and all other graphics resource for a game? Or is better to have for example: a medium gif file holding all tiles, a gif file for each sprite?
    In my opinion the second way is better, because I think that a big gif file is difficult to handle because I will have to crop individual tiles and frames for the sprite animation and the image gets a messy.
    But anyway I just wanna heard your opiniions about this issue.
    Tks

    It totally depends on the number of colors in your images.
    Remeber a GIF is limited to 256 colors, if you need more than this you will obviously have to split your tiles & animation frames across multiple gifs.
    Ofcourse, the better solution is to use PNGs.
    There is also the consideration of acceleration - large images will not be cached in vram, if you look at the assets of commercial titles, you will find the best size to go for is either 256x256 or 512x512.
    You should perform the cropping as you render the images, as it will be no slower than precropping them, and will take a good deal less vram. (a 20x20 image when cached in vram will be expanded to 32x32)

  • How to resize a gif image

    hi
    i need to resize a gif image to my preferable height and width . i have copied some code from net , its working fine for small images . but when i resize large images the background becomes back .... so
    any body help me put in this....
    regards
    mano

    hi
    thanks for ur reply . can u plz tell me were to insert the code here
    Image image = Toolkit.getDefaultToolkit().getImage("C:\\image.gif");
    MediaTracker mediaTracker = new MediaTracker(new Container());
    mediaTracker.addImage(image, 0);
    mediaTracker.waitForID(0);
    // determine thumbnail size from WIDTH and HEIGHT
    int thumbWidth = Integer.parseInt("120");
    int thumbHeight = Integer.parseInt("75");
    double thumbRatio = (double)thumbWidth / (double)thumbHeight;
    int imageWidth = image.getWidth(null);
    System.out.println("imageWidth "+ imageWidth);
    int imageHeight = image.getHeight(null);
    double imageRatio = (double)imageWidth / (double)imageHeight;
    if (thumbRatio < imageRatio) {
    thumbHeight = (int)(thumbWidth / imageRatio);
    } else {
    thumbWidth = (int)(thumbHeight * imageRatio);
    // draw original image to thumbnail image object and
    // scale it to the new size on-the-fly
    BufferedImage thumbImage = new BufferedImage(thumbWidth,
    thumbHeight, BufferedImage.TYPE_INT_RGB);
    Graphics2D graphics2D = thumbImage.createGraphics();
    graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
    RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    graphics2D.drawImage(image, 0, 0, thumbWidth, thumbHeight, null);
    // save thumbnail image to OUTFILE
    BufferedOutputStream out = new BufferedOutputStream(new
    FileOutputStream(args[1]));
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    JPEGEncodeParam param = encoder.
    getDefaultJPEGEncodeParam(thumbImage);
    int quality = Integer.parseInt("75");
    quality = Math.max(0, Math.min(quality, 100));
    param.setQuality((float)quality / 100.0f, false);
    encoder.setJPEGEncodeParam(param);
    encoder.encode(thumbImage);
    out.close();
    System.out.println("Done.");

  • Gif image display problem

    I can't get QuickTime to display gif images from the web. It will show the same gif file on my local machine, but if I put it on the web it will no longer display. My web browser shows that the url is valid, and will display the gif image. But QuickTime returns a "Error 47: Invalid URL" I have tried multiple computers, and have the same problem.

    First.
    You don't need a browser plug-in to display a .gif file and you really don't want to use QuickTime plug-in to display them.
    If you can view the .gif in a blank browser window (all by itself) copy that URL.
    Open QuickTime Player and Control-U. Paste the URL and see what happens.
    My blue Q has this URL:
    http://supportdownload.apple.com/discussions.apple.com/avatar-display.jspa?avata rID=111&file=av.png
    It is a .png file file but any image format could be used. Copy the URL and test to see how it works.

  • Drawing multiple shape

    I am working on a small program to draw multiple shape, I am having problem because I can not draw more than one shape on the screen at the same time . can you help me pls
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.applet.Applet;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.geom.Rectangle2D;
    import java.awt.Color;
    public class BoxClickApplet extends Applet
    int x1,y1;
    int click=-1;
              class MyMouseListener implements MouseListener
              public void mousePressed(MouseEvent event){}
              public void mouseReleased(MouseEvent event){}
              public void mouseClicked(MouseEvent event)
                   click++;
    if (click==0)
                                  x1=getWidth()/2-20;
                                  y1=getHeight()-40;
                                  repaint();
                                  ((Graphics2D)g).fill(r);
                   if (click==1)
                                  x1=getWidth()/2-20;
                                  y1=getHeight()/2-20;
                                  repaint();
                   if (click==2)
                                  x1=getWidth()/2-20;
                                  y1=0;
                                  repaint();
    if (click==3)
                             x1=getWidth()/2-20;
                             y1=getHeight()/2;
                             repaint();
                             x1=getWidth()/2-20;
                             click=-1;
    public void mouseEntered(MouseEvent event){}
              public void mouseExited(MouseEvent event){}
    MyMouseListener listener = new MyMouseListener();
    addMouseListener(listener);
    public void paint(Graphics g)
         g.setColor(Color.GREEN);
         Rectangle2D.Double r = new Rectangle2D.Double (x1,y1,40,40);
    ((Graphics2D)g).fill(r);

    //  <applet code="BCA" width="400" height="400"></applet>
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.BufferedImage;
    public class BCA extends Applet
        BufferedImage image;
        int width = 40;
        int height = 40;
        public void init()
            addMouseListener(new MyMouseListener());
        public void paint(Graphics g)
            if(image == null)
                initImage();
            g.drawImage(image, 0, 0, this);
        private void initImage()
            int w = getWidth();
            int h = getHeight();
            int type = BufferedImage.TYPE_INT_RGB;
            image = new BufferedImage(w, h, type);
            Graphics2D g2 = image.createGraphics();
            g2.setBackground(getBackground());
            g2.clearRect(0,0,w,h);
            g2.dispose();
        private void addRectangle(Point p)
            Graphics2D g2 = (Graphics2D)image.getGraphics();
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setColor(Color.GREEN);
            g2.fill(new Rectangle(p.x-width/2, p.y-height/2, width, height));
            g2.dispose();
        private void clearImage()
            Graphics g = image.getGraphics();
            g.setColor(getBackground());
            g.fillRect(0, 0, image.getWidth(), image.getHeight());
            g.dispose();
        class MyMouseListener extends MouseAdapter
            public void mousePressed(MouseEvent event)
                if(event.getClickCount() == 2)
                    clearImage();
                else
                    addRectangle(event.getPoint());
                repaint();
    }

  • Transparency gif image for icon

    Hi all,
    I am trying to do some art work with Microsoft paint. I am trying to draw an icon(a gif image).
    Microsoft paint? Is there any other tool that I can use?
    I have problem with the transparancy color. It keep showing up even I set the color to be RGB(153,153,153) Any idea guys?
    Thanks

    In my experience, if there is a GIF image that already contains transparent pixels, you can show it using "ImageIcon.class" directly without the need to set any RGB color yourself.

  • Servlet to generate JPG/GIF image

    I've got sth like that:
    response.setContentType("image/gif");
    OutputStream out = response.getOutputStream();
    Image messageImage = makeMessageImage(message, fontName, fontSize);What I should do next to send it to the browser and display it?

    You can create a BufferedImage, draw messageImage onto it, and then send the BufferedImage through the OutputStream via
    ImageIO.write(theBufferedImage, "gif", out); Or if messageImage is already a BufferedImage, then you can just send it directly after casting it.
    There's a slight complication, however. The GIF format uses palette-based images. If you send an image that's not palette-based then it will use the default palette. It's the same as if I had created this
    BufferedImage theBufferedImage = new BufferedImage(
            messageImage.getWidth(null),
            messageImage.getHeight(null),
            BufferedImage.TYPE_BYTE_INDEXED); drew messageImage onto it and then sent it. The default palette almost certainly isn't the 256 most representative colors in your message image. This may or may not be a problem. I don't know the kind of quality you want. If your image doesn't have any color, a viable alternative is TYPE_BYTE_GRAY.
    Ideally, for a full-colored image you would create an IndexColorModel of what you feel is the 256 most representative colors in the image. Then you would create a BufferedImage using this palette, draw the original image onto it, and send it off.

  • 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

Maybe you are looking for