Solved

Highlighting Buttons on MouseOver

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Printing to a specific printer tray (HP 806dn printer) 3 83
for i loop in grovy 1 46
JDeveloper 12c for 32 bit 4 71
Windows 10 IE Certificate Issue 10 42
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

867 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

15 Experts available now in Live!

Get 1:1 Help Now