Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Image+Button+applet

 
Ramesh Devendra
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir,
Thanks your kind response,
Q1.Previous day you send code in click event GIF file become
change(So our requiremet is fullfil)but one problem arise that
i want click button in out side of GIF image.please sir give
me response.you send this code

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.util.*;
public class ImageButtonApplet02 extends Applet implements ActionListener{
private Vector v;
private int numOfImages;
private int currentImage;
private Button b;
public void init()
{
v = new Vector( 10 );
numOfImages = 0;
currentImage = 0;

// The next few lines add three images to the vector
// These were just some images I had laying around
// If you have numbered images it would be much better to
// make a loop that loops through all your images
// or perhaps pass all of them in as parameters to the
// applet... It's your decision.
Image tempImage = getImage(getCodeBase(),"c:/RAMESH/newbanner111.jpeg.jpg" );
v.insertElementAt( tempImage, numOfImages );
numOfImages++;
tempImage = getImage( getCodeBase(), "c:/RAMESH/fman_mainscreen.gif" );
v.insertElementAt( tempImage, numOfImages );
numOfImages++;
tempImage = getImage( getCodeBase(), "c:/RAMESH/mona.jpeg" );
v.insertElementAt( tempImage, numOfImages );
numOfImages++;
(HOW TO DO BUTTON OUT SIDE OF GIF IMAGE)
Button b = new Butto( "Next!" );
b.addActionListener( this );

add( b );
}

public void paint( Graphics g )
{
Image i = ( Image )v.elementAt( currentImage );
g.drawImage( i, 0, 0, this );
}

public void actionPerformed( ActionEvent e )
{
currentImage = (currentImage + 1 ) % numOfImages;
repaint();
}
}
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure what you mean by outside of image... if you want a border area around the image with a button on it that would be simple enough to do...

Basically, I moved most of the image stuff into an inner class, and then basically made the applet save the vector and handle the button... Is this what you wanted?
NOTE : I had problems with NullPointerExceptions unless I specifically initialized the ImagePanel with an Image... you may want to make ImagePanel a little more robust if you have problems...
HTH,
-Nate
[This message has been edited by Nathan Pruett (edited April 04, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic