I have a class in which I am implementing the events of a frame and I want to make every time that double-clicking on a table opens another window and shows me the data of that object, I am implementing the mouseListener interface to the class and add it to Jtable so that I can run the event.
This is the class where I implement the interfaces and add the mouseListener interface to the table. EYE : I will only post the events implemented by mouseListener because they are of interest in this case:
public class ControladorEstudiante implements ActionListener, KeyListener, MouseListener{
private DBConnection dbcon;
EstudianteAdmin estAdmin= new EstudianteAdmin();
MostrarEstudiante estMostrar= new MostrarEstudiante();
EstudianteDAOImpl estDAO= new EstudianteDAOImpl(dbcon);
public ControladorEstudiante(EstudianteAdmin estAdmin, MostrarEstudiante estMostrar, EstudianteDAOImpl estDAO){
this.estDAO= estDAO;
this.estAdmin= estAdmin;
this.estMostrar= estMostrar;
this.estAdmin.getTablaEstudiante().addMouseListener(this); }
public void InicializarCrud(){
}
@Override
public void keyReleased(KeyEvent ke) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void mouseClicked(MouseEvent me) {
if(me.getClickCount()== 2){
int fila= estAdmin.getTablaEstudiante().getSelectedRow();
if(fila>-1){
estMostrar.getTxtNombre().setText(estAdmin.getTablaEstudiante().getValueAt(fila, 0).toString());
estMostrar.getTxtMatricula().setText(estAdmin.getTablaEstudiante().getValueAt(fila, 1).toString());
estMostrar.getTxtNota().setText(estAdmin.getTablaEstudiante().getValueAt(fila, 3).toString());
}
}
}
@Override
public void mousePressed(MouseEvent me) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void mouseReleased(MouseEvent me) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void mouseEntered(MouseEvent me) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void mouseExited(MouseEvent me) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
As you can know the method I have for when two click on the table is the mouseClicked , however, when loading the data from the Database into the table I immediately move the mouse over the jtable, I get an error, then I leave the stacktrace :
Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not supported yet.
at comm.estudiante.dao.controlador.ControladorEstudiante.mouseEntered(ControladorEstudiante.java:425)
at java.awt.AWTEventMulticaster.mouseEntered(AWTEventMulticaster.java:300)
at java.awt.Component.processMouseEvent(Component.java:6544)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6300)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4891)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4713)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
at java.awt.LightweightDispatcher.retargetMouseEnterExit(Container.java:4676)
at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4654)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4505)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4713)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Another thing is that when I implement the mouseListener interface on the Jtable, it is not selected, I do not know why.