problem with keyadapter / java application

M

Michi

hello,

i have the following problem
i wrote a java application with an oracle connection.

i tried to add keylistener in order to interact from my keyboard...
but i doesn't work.

i do things like that:

public void press_abbruch(JButton b)
{
b.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
Object[] msg_abbruch = {"cancel?"};
int frag_abbruch =
JOptionPane.showConfirmDialog(null,msg_abbruch,"Abbruch",
JOptionPane.YES_NO_OPTION,JOptionPane.ERROR_MESSAGE);

if(frag_abbruch == 0)
{
System.exit( 0 );
}
else
{
}
}
}); // Ende MouseListener

b.addKeyListener(new KeyAdapter()
{
public void keyPressed(KeyEvent e)
{
Object[] msg_abbruch = {"cancel?"};
int frag_abbruch =
JOptionPane.showConfirmDialog(null,msg_abbruch,"Abbruch",
JOptionPane.YES_NO_OPTION,JOptionPane.ERROR_MESSAGE);

if(frag_abbruch == 0)
{
System.exit( 0 );
}
else
{
}
}
}); // Ende KeyListener

i guess the mistake could be that i wrote a java class that includes
only my functions - could it be that i call the functions wrong?

if i want to call my functions i can't tab in my application? why?

Michi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top