Solved

Highlighting Buttons on MouseOver

Posted on 1997-07-17
1
200 Views
Last Modified: 2012-08-14
I would like to know how I can highlight a button when you place the mouse over it (similar to how Netscape Communicator or Internet Explorer does it).  Some source code would be appreciated.  Thanks.
0
Comment
Question by:Yoda
1 Comment
 
LVL 2

Accepted Solution

by:
mgk earned 50 total points
ID: 1223255
That's pretty easy - use the mouse events to trigger the use of a new image. I've left some stuff out of this applet but you should get the hang of it from this;

Boolean  on;
Image    onimage,offimage;

public void init() {
onimage=getImage(getCodeBase(),"onimage.gif");
offimage=getImage(getCodeBase(),"offimage.gif");
}

public synchronized void paint(Graphics g) {
   if (on) g.drawImage ( onimage, 0, 0, this );
   if (!on) g.drawImage ( offimage, 0, 0, this );
}
 
public boolean mouseEnter(Event e, int x, int y)  {
   on=true;
   repaint();
   return true;
}  
      
public boolean mouseExit(Event e, int x, int y)  {
   on=false;
   repaint();
   return true;
}  

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now