Solved

problem with Object flicker on MouseEvents

Posted on 1998-11-11
4
209 Views
Last Modified: 2010-03-30
public class Applet1 extends Applet
{
    private class MyEvent implements java.awt.event.MouseListener
    {
        public void mouseClicked (java.awt.event.MouseEvent mlEvent)
        {
        }
       
        public void mousePressed (java.awt.event.MouseEvent mEvent)
        {
        }
       
        public void mouseReleased (java.awt.event.MouseEvent mEvent)
        {
        }

        public void mouseEntered (java.awt.event.MouseEvent mEvent)
        {
        }

        public void mouseExited (java.awt.event.MouseEvent mEvent)
        {
        }
       
        private void FretBoard_Clicked (Object obj, java.awt.event.MouseEvent mlEvent)
        {
        }
    }

    //{{DECLARE_CONTROLS
   /}}
   
  public void init()
  {
  //{{INIT_CONTROLS
 setLayout(null);
 setBounds(0, 0, 640, 480);
 
 ImageButton imgFret = new ImageButton();
 imgFret.setBevelHeight(0);
 imgFret.setImageURL(new java.net.URL("file:///C:/FretBoard.jpg"));
  imgFret.setBorderColor(new java.awt.Color(16777215));
  imgFret.setButtonColor(new java.awt.Color(16777215));
  imgFret.setImageStyle(symantec.itools.awt.ImageButton.IMAGE_NORMAL);
  imgFret.setUseOffset(true);
  imgFret.setNotifyDelay(0);
  imgFret.setBounds(24, 24, 602,155);

  add (imgFret);

 // Add MouseListener to the Image Component
 imgFret.addMouseListener (new MyEvent());
 //}}
}
}  



Hello,
The above extract of code places an image (extends java.awt.Component) onto a panel and adds a listener for the mouseevents.

It is possible to click on the images but the image flickers everytime the mouse button is depressed.  How can I avoid this flicker?

Thanks for any help you can offer,

Rob.
0
Comment
Question by:robertod031297
  • 3
4 Comments
 
LVL 16

Expert Comment

by:heyhey_
ID: 1227222
there are two possible reasons for flickering
1. this can be a platform problem - try the applet with different browsers & appletviewer
if it does not depends on the JavaVM implementation then
2.) it should be Symantec's fault
  ( I saw this line 'symantec.itools.awt.ImageButton.IMAGE_NORMAL')
check the documentation from symantec and maybe some examples ...

:-) i've seen many images that does not flicker. I'd recomend you not to use third party componnent for simple applets - at least if you write them yourself, you'll know exactly what happens ...

hope this helps
  heyhey
0
 
LVL 16

Accepted Solution

by:
heyhey_ earned 50 total points
ID: 1227223
there are two possible reasons for flickering
1. this can be a platform problem - try the applet with different browsers & appletviewer
if it does not depends on the JavaVM implementation then
2.) it should be Symantec's fault
  ( I saw this line 'symantec.itools.awt.ImageButton.IMAGE_NORMAL')
check the documentation from symantec and maybe some examples ...

:-) i've seen many images that does not flicker. I'd recomend you not to use third party componnent for simple applets - at least if you write them yourself, you'll know exactly what happens ...

hope this helps
  heyhey
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 1227224
Sorry :((
damn browsers ...
0
 

Author Comment

by:robertod031297
ID: 1227225
Hello heyhey_ (wtf?)

I spotted the problem in reading your answer.  This component was originally a blank imagebutton and I wanted to replace the imagebutton with a plain image.  The fact that it's a button means it responds visually to mouseclicks and that explains my flicker - it's just the button responding.

Take Care,

Rob.

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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 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:

758 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