[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

how to pop up a frame when mouse at certain area?

hello......
i have a applet which cointain a pic, and i would like to pop up a frame when user's mouse move around that area.....but it always pop up to many frame(i think so, bcoz i have to close many time only the frame close)........my pic applet is in one file...and the frame is in another file

thannks
0
bhuey_ling
Asked:
bhuey_ling
  • 3
  • 2
1 Solution
 
vivexpCommented:
Hi,

Use a static boolen variable which will keep track of the instance created by pop up frame class. Then u can avoid creating multiple instances of the same frame.

or

Create a singleton class ...

Try out....



 
0
 
bhuey_lingAuthor Commented:
hello....
well ..actually wat i use dialog box.......but i thinnk it is same as frame......could u be more specified......like write the code....i dun know how to handle this between 2 file..thanx
0
 
vivexpCommented:
Hi,

I created two files Frame1.java  and StandardDialog1.java extends JDialog.

Ur Frame can also be an applet.

In Frame1.java
Declare...
public static boolean dialogflg=true;


Under mousemovelistener ()
if(sdf==true){
    StandardDialog1 sd = new StandardDialog1(this);
    sd.show (true);
    dialogflag=false;
  }
 }

Compile both the files and put them in the same package.

Try out...


0
 
bhuey_lingAuthor Commented:
hello!
i would like to ask if i want the boolean activate each time the dialog box dipose...how can i do it?

thanx.....
0
 
bhuey_lingAuthor Commented:
hello!.....
below is my program ....it is written in old style (didn't use listener)....but it have a problem that it pop up two dialog box each time my mouse come to that area.....how to solve it?


boolean dialogflg = true;
    public boolean mouseMove(Event e, int x, int y){  
      Frame f=new Frame("InfoDialog Test");
      f.resize(100,50);
      InfoDialog dlg=new InfoDialog(f,"Think about it!",
      " hahaha");      
      if(x<180 && x>10 && y<190 && y>10&&dialogflg==true){              
      dlg.show(true);
      dialogflg=false;
      }
      else if(x>180 || x<10){
           dialogflg=true;
      }                  
      return true;
    }
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now