I get the error message:
The method showInternalConfirmDialog(Component, Object, String, int,
int) in the type JOptionPane is not applicable for the arguments (new
KeyListener(){}, String, String, int, int)
public void keyTyped(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
System.out.println("Key Released F1");
if(e.getKeyCode()==KeyEvent.VK_F1) {
/*here i get the error*/ int choice = JOptionPane.showInternalConfirmDialog(this, "Would you like to play the movie? "
,"Message", JOptionPane.WARNING_MESSAGE
, JOptionPane.OK_CANCEL_OPTION);
Any idea why I get this error?
Assuming your extending a JFrame, JFrame doesn’t extend JComponent. I think this is the reason why it doesn’t work. AS a work around I suggest using a JPanel, this code compiled and worked.
Hope this helps.
Edited I’ve just noticed I coded without the “F1” button condition implemented, I got rid just to simplify.