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
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
  • 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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…
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:
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.
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

770 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