As an achievement that my jpanel gets in front of another JAVA

1

I am trying to make my jpanel get in front of the table when I right click on the table. But what makes me is that is behind this as seen in the image

This is the part of the code

I appreciate any kind of help

    
asked by Daniel Morales 07.06.2018 в 02:10
source

1 answer

0

You can choose to use the component JPopupMenu , which is designed just to meet that need you pose, so that for example:

JPopupMenu POP = new JPopupMenu();
JMenuItem DEL = new JMenuItem("Borrar");
JMenuItem SHOW = new JMenuItem("Mostrar");
POP.add(DEL);
POP.add(SHOW);

miTabla.addMouseListener( new MouseAdapter() {
  public void mousePressed( MouseEvent evt ) {
    if( evt.isPopupTrigger() ) {
      POP.show( miTabla, evt.getX(), evt.getY() );
    }
  }
} );

But I want to dwell on the following, it depends on each operating system as a contextual menu is displayed, I mean for example, Windows (I do not know if in all current versions) uses an event of mouseReleased to show options with the right button but in MacOS the event is mousePressed ... Then the advisable thing is to implement all the methods of mouseListener .

Finally isPopupTrigger() basically says with a boolean if the left button has been pressed ( false ) or if you have clicked with the right button ( true ).

    
answered by 07.06.2018 / 03:49
source