Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8338109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:29:35+00:00 2026-06-09T04:29:35+00:00

How can I target (in JXTable) a specific column values from different rows to

  • 0

How can I target (in JXTable) a specific column values from different rows to open a new frame when I double click?

enter image description here

I have this code for now:

myTable.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    JXTable target = (JXTable)e.getSource();
                    int row = target.getSelectedRow();
                    int column = target.getTableColumn(3);  //for example the third column
                    new Detail().setVisible(true);

                }
            }
        });

Solved with this code:

     final JOptionPane pane = new JOptionPane((Frame) null, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION);

     final JDialog d = pane.createDialog((Frame) null, "Comments");
                   d.setModal(false);
                   d.setAlwaysOnTop(true);
                   d.pack();
     myTable.addMouseListener(new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
                   if (e.getClickCount() == 2) {
                          int row = myTable.rowAtPoint(e.getPoint());
                          Object value1 = myTable.getValueAt(row, 4);
                          pane.setMessage(value1);
                   if (!d.isVisible())
                   d.setLocationRelativeTo(myTable);
                   d.setVisible(true);
                   }
          }
      });

UPDATE 1:

As @mKorbel said, I want to use a JPopupMenu like this example (provided by @mKorbel). But how can I implement a JDialog which opens when the JMenuItem is clicked.

private void createPopupMenu() {
        JPopupMenu popup = new JPopupMenu();
        JMenuItem MenuItemComments = new JMenuItem("Show Comments");
        JMenuItem MenuItemReference = new JMenuItem("Show Reference");
        popup.add(MenuItemComments);
        popup.add(MenuItemReference);

        MouseListener popupListener = new PopupListener(popup);
        Table_Employee.addMouseListener(popupListener);
    }

private class PopupListener extends MouseAdapter {
        private JPopupMenu popup;
        PopupListener(JPopupMenu popupMenu) {
            popup = popupMenu;
        }
        @Override
        public void mousePressed(MouseEvent e) {
            maybeShowPopup(e);
        }
        @Override
        public void mouseReleased(MouseEvent e) {
            if (Table_Employee.getSelectedRow() != -1) {
                maybeShowPopup(e);
            }
        }
        private void maybeShowPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {

        // get row that pointer is over
        int row = Table_Employee.rowAtPoint(e.getPoint());

        // if pointer is over a selected row, show popup
        if (Table_Employee.isRowSelected(row)) {
           popup.show(e.getComponent(), e.getX(), e.getY());

        }
            }

        }


    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:29:36+00:00Added an answer on June 9, 2026 at 4:29 am
    1. don’t create a new J(X)Frame on runtime, contents of this container will be the same, no reason for that, create that once time, reuse this container, and for visibility on the screen (to hide / show) use setVisible(false / true)

    2. don’t create a J(X)Frame, create a J(X)Dialog with parent to the JXTable, then dialog will be centered to the JXTables

    3. you can to use ListSelectionListener too, but with single selection model

    4. read Oracle tutorial about JList, JTable and ListSelectionListener, logics will be the same and for SwingX components too,

    5. I’d be use JPopup as control for displaying the JDialog, just to avoids annoying events came from mouse or keyboard

    EDIT

    have to add

    • d.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE), then JDialog never will be closed only changed to the setVisible(false);

    • have to code value from selected JTables row,

    • create a new, separate void that fills value from JTables row to the JComponents placed into JDialog

    • be ensure that J(X)Table has changed selectionMode to the single selection

    • (not required) now you can possitioning JDialog on the screen, JDialog still is not visible on the screen

    • thenafter to call d.setVisble(true), I’d suggest wrap this code line to the invokeLater(), then JDialog will be visible after all changes are done, move this event to the end of the Event Dispatch Thread

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that I can target elements which have a specific attribute in CSS,
My question is how can I make the hyperlinks from a JXTable column (just
I know in Visual Studio 2008 you can target a specific framework with your
Normally we can specify a target in the link or use javascript window.open to
I am developing a silverlight application where you can set sales target for specific
Is there a specific version of .Net that I can target that is bundled
I am wondering how I can target a specific commit SHA in Git for
I understand that css rules can target elements specified by attribute values, e.g.: input[type=text]
I want to develop a program in c# that can target and application or
I'm trying to change the color of the Asterisk but I can't target the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.