Java popup, Jpanel and PopupFactory - update x and y coordinates

I have a Jpanel, which I want to add a info popup on right click. So, the coordinates of the popup can change. However, when I add a popup in the paintComponent method, the application slows down considerably.

I am using the following code to get an instance of the popup from the popupFactory in the paintComponent:

public void paintComponent(java.awt.Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g;

if(Show){
    popup = factory.getPopup(this, l, mouseX, mouseY); 
    popup.show();
}

l is a simple JLabel. Is there another way to add an info popup on right click on a Jpanel.

Cheers,

Slotishtype

Answers


Is there another way to add an info popup on right click on a Jpanel.

The normal way is to use a MouseListener and to listen for the right mouse click and then display the popup. The paintComponent() method has nothing to do with displaying popups, since the popup is not part of the component.


Need Your Help

Selenium IDE target of subsequent cell in table based on first cells content

selenium-ide

Basically, in English I want to tell Selenium "look for the content ttc202 in column one, of a multi-row, multicolumn table, then mouseOver on the Edit link"

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.