problem with keyadapter / java application

Discussion in 'Java' started by Michi, Jul 14, 2003.

  1. Michi

    Michi Guest

    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
    Michi, Jul 14, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page