• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Image+Button+applet

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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();
}
}
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
He does not suffer fools gladly. But this tiny ad does:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic