This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Image+Button+applet

 
Greenhorn
Posts: 4
  • 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();
}
}
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • 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).]
 
Uh oh, we're definitely being carded. Here, show him this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic