PDA

View Full Version : JButton in JTable, problema con ActionEvent


tylerdurden83
02-01-2009, 16:22
Quoto una descrizione di un pezzi di codice che ho preso in giro:

At this point, you're almost done, but not quite. What's the use of putting a JButton in a JTable if you
can't press the darn thing? By default, JTable will not forward mouse events to components contained in its
cells. If you want to be able to press the buttons you add to JTable, you have to create your own MouseListener
that forwards events to the JButton cells. JTableButtonMouseListener demonstrates how you could do this.

Premesso che i JButton non inseriti nella JTable funzionano, quelli nella JTable no. Da quanto ne evinco dal quote, il metodo che ho preso serve a passare un mouseEvent dalla cella della JTable al component in essa contenuto, quindi passa un mouseHover o mouseClicked al component, il bottone stesso, e poi perņ?... Come innesco il classico ActionEvent dei bottoni NON contenuti in JFrame?

Grazie a tutti,
TD

cionci
03-01-2009, 00:37
http://www.hwupgrade.it/forum/showthread.php?t=1649196