Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


How to Create popup in Jtable?

Posted on 2005-03-17
Medium Priority
Last Modified: 2008-03-17
I need to create a popup in a Jtable, when the mouse is clicked on a cell in a jtable, a popup needs to be displayed.  I am unfamilar with creating a popup.
Question by:DanFlyBoy
  • 4
LVL 37

Expert Comment

ID: 13565258
You can use JOptionPane.showMessageDialog()
LVL 37

Expert Comment

ID: 13565274
Different examples at http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html

     JOptionPane.showMessageDialog(new JFrame(), "Hello world!");

just works
LVL 37

Accepted Solution

zzynx earned 300 total points
ID: 13565327
>> when the mouse is clicked on a cell in a jtable, a popup needs to be displayed

Try this:

yourTable.addMouseListener( new MouseAdapter() {
     public void mouseClicked(MouseEvent e) {

         int col = yourTable.columnAtPoint(e.getPoint());
         int row = yourTable.rowAtPoint(e.getPoint());
         if (col!=-1 && row!=-1)
             JOptionPane.showMessageDialog(new JFrame(),
              "You just clicked on cell [" + row + ", " + col + "]");

LVL 37

Expert Comment

ID: 13565445

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

577 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