MouseOver

I am trying to write an applet button that when the mouse scrolls over it it will give a bubble help type windows
help description sort of like the ALT tags function describing the buttons description and when the mouse is not over the windows help type screen goes away. And also trying to make button a link when actually clicked
on
jbird090897Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

thornerCommented:
Create a bubble image and the in mouseover load the image.
0
jbird090897Author Commented:
scratch the bubble image,i am trying to make a standard button that when the mouse moves over it, it gives a description of that button,its sort of like on a windows95 system
if you pass the mouse over one of the icons it gives a small yellow help box
0
aziz061097Commented:
This is a property in Swing TextFields .
0
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

thornerCommented:
Use a separate method to draw a box and insert text into that box.  When the mouse goes over the button load that method.  That's the easiest way I can think of.  As far as the link part, try this:

import java.net.*;

public class URL extends Applet implements ActionListener
{    
     private Button link;

     public void init()
     {
          URL url;

          url = new URL("http://yourURL.com");
     
          link = new Button("Click Here...");
          add(link);
          link.addActionListener(this);
     }

     public void actionPerformed(ActionEvent e)
     {
          if(e.getSource() == link)
               getAppletContext().showDocument(url);
     }
}

Add the rest of the code for the button to this. It should work.
0
jbird090897Author Commented:
How do i use another method to draw the box and add text to ,
i am alittle bit of a beginner and dont know how toi just tried to compile the java code
and it had errors undefined name  Applet. I named the applet  URL maybe that
could be the problem.
0
thornerCommented:
Okay, I forgot some things.  Try this:

      import java.applet.Applet;
      import java.awt.*;
      import java.awt.Event.*;
      import java.net.*;

      public class URL extends Applet implements ActionListener
      {      
           private Button link;

           public void init()
           {
                URL url;

                url = new URL("http://yourURL.com");
           
                link = new Button("Click Here...");
                add(link);
                link.addActionListener(this);
           }

           public void actionPerformed(ActionEvent e)
           {
                if(e.getSource() == link)
                     getAppletContext().showDocument(url);
           }
      }

Okay, save the applet as URL. Make the HTML file to view it. If you are a beginner I still think that loading an image on mouseover is better.  Make the image in a graphics program that states the description of the button and then make it load when you want it to.
0
jbird090897Author Commented:
Thanks
0
jbird090897Author Commented:
Thorner,
I thought i was done,
I compiled your code under Visualj++ and recieved the following error
undefined package 'Event' thats probably because the it doesn't have the java.awt.event in
it- so that solves that one.
And compiled in JDK1.2 i get 1 error
"Interface Actionlister of class URL no found"
0
thornerCommented:
Check that your type ActionListener and not Actionlister.

"Interface Actionlister of class URL no found"
0
jbird090897Author Commented:
Thorner I did type Actionlistener on both all i did was copy what you have here.Have
you tried to compile the code. If you could compile it i'll just reinstall jdk and visualJ++
0
thornerCommented:
Now, here's what I have but I can't get it to work. We're gonna have to leave it up to other experts I guess. I thought this would work but I guess not. The reason for the error messages before was because of the capital E in event. That was my fault.
This code has 1 error in it.

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.net.*;

public class URL extends Applet implements ActionListener
{      
      private Button link;
        private URL url;
        private String location;

        public void init()
        {
                location = "http://www.yoursitehere.com";
                url = new URL();
                   
                link = new Button("Click Here...");
                add(link);
                link.addActionListener(this);
        }

        public void actionPerformed(ActionEvent e)
        {
                URL url = (URL) e.getSource();
                getAppletContext().showDocument(url);
        }
}

0
knollcCommented:
VJ++ doesn't support the new event model so forget ActionListener in J++.
0
knollcCommented:
VJ++ doesn't support the new event model so forget ActionListener in J++.
0
jbird090897Author Commented:
ok true but what about jdk1.2?
0
thornerCommented:
Jbird,
The ActionListener part of the program is fixed in the above code.  The only problem now is that the code in the actionPerformed method is incorrect.  I don't know why it doesn't work, but try compiling that for yourself and see what you get.
0
cphCommented:
Here is the working code (at least it compile ;):

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.net.*;

public class UrlApplet extends Applet implements ActionListener
{private Button link;
private URL url;
private String location;

public void init()
      {location = "http://www.sitehere.com";
         try {url = new URL(location);
              link = new Button("Click Here...");
              add(link);
              link.addActionListener(this);
           }
       catch (MalformedURLException BadURL)
            {//Anything you want
            }
        }

public void actionPerformed(ActionEvent e)
      {URL url = (URL) e.getSource();
         getAppletContext().showDocument(url);
        }
}

Note: Name your file the name of the class.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.