Solved

Highlighting Buttons on MouseOver

Posted on 1997-07-17
1
223 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Python Assistance 7 81
jar file executable 12 52
eclipse shortcuts 9 55
split string containing \r\n in Java 46 44
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

777 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