Solved

MouseOver

Posted on 1998-05-13
16
356 Views
Last Modified: 2010-04-16
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
0
Comment
Question by:jbird090897
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
  • 2
  • +2
16 Comments
 

Expert Comment

by:thorner
ID: 1220977
Create a bubble image and the in mouseover load the image.
0
 

Author Comment

by:jbird090897
ID: 1220978
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
 
LVL 2

Expert Comment

by:aziz061097
ID: 1220979
This is a property in Swing TextFields .
0
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 

Expert Comment

by:thorner
ID: 1220980
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
 

Author Comment

by:jbird090897
ID: 1220981
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
 

Expert Comment

by:thorner
ID: 1220982
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
 

Author Comment

by:jbird090897
ID: 1220983
Thanks
0
 

Author Comment

by:jbird090897
ID: 1220984
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
 

Expert Comment

by:thorner
ID: 1220985
Check that your type ActionListener and not Actionlister.

"Interface Actionlister of class URL no found"
0
 

Author Comment

by:jbird090897
ID: 1220986
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
 

Expert Comment

by:thorner
ID: 1220987
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
 

Expert Comment

by:knollc
ID: 1220988
VJ++ doesn't support the new event model so forget ActionListener in J++.
0
 

Expert Comment

by:knollc
ID: 1220989
VJ++ doesn't support the new event model so forget ActionListener in J++.
0
 

Author Comment

by:jbird090897
ID: 1220990
ok true but what about jdk1.2?
0
 

Expert Comment

by:thorner
ID: 1220991
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
 
LVL 1

Accepted Solution

by:
cph earned 150 total points
ID: 1220992
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

688 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