[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

JPopupMenu....

Posted on 1998-09-23
2
Medium Priority
?
615 Views
Last Modified: 2008-02-26
I am using the JPopupMenu in response to a button being pressed.  The popup menu shows when I press the button, but if I move the frame which the test app sits in, the popup menu disappears.  Why is this and how can I fix it?
0
Comment
Question by:beemer
[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
2 Comments
 
LVL 2

Expert Comment

by:shchuka
ID: 1224879
I think this is how popup menus behave - they disapper if you move the frame.  Thus you can't really do anything to keep it open.  On the other hand, you can simulate this behavior by declaring some boolean variable that is equal to true if the menu is open and is set to false when it's closed.  Now, when you do something which might close the menu, in that event check whether this variable is set and if yes, open the menu.
0
 
LVL 3

Accepted Solution

by:
sailwind earned 100 total points
ID: 1224880
Popup menus will only appear when you click on the item that generates the
popup menu. When you click on another component, Java assumes that you
no longer want to work with the popup menu and therefore closes it. This is
the way normal windows work. For example, if you pull down the file menu,
but click somewherelse on the screen before making the selection, the file
menu will close since it assumes you don't want it anymore. Same concept.

When you move the window, java takes this as a sign that you want to
interact with the frame now, not the popup menu, and will therefore close the
popup menu.

What you can do is add a componentListener to your window. In your listener,
define the method componentMoved() to pop up the popupmenu if it is needed.
You can use a simple boolean flag like shchuka suggested.

Hope this helped!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

649 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