call an event from another event [Solved]

Hi everyone, I'm a new user IntelliJ IDEA and Java and I have a class of my Form and this form contains two controls: button1 and textField1.
The control "button1" has programmed the metod "mouseClicked" where the application title change getting textField1 text, but... I can make this when the user
press "Enter" on the button, and I can call the event "mouseClicked" into the event "KeyReleased".

My source code is:

button1.addMouseListener(new MouseAdapter() {
               @Override
               public void mouseClicked(MouseEvent e) {
                    frame.setTitle(textField1.getText());
               }
          });

          button1.addKeyListener(new KeyAdapter() {
               @Override
               public void keyReleased(KeyEvent e) {
                    if(e.getKeyCode() == KeyEvent.VK_ENTER){
                         //Here the call to button1.mouseClicked(null); ?????

                    }
               }
          });


Thank's and sorry for my bad english.
Greetings.


/********************************************* Edited an minutes ago *****************************************************/

Thank's all, but I have found the solution to this, and my source code finally is this:

button1.addMouseListener(new MouseAdapter() {
               @Override
               public void mouseClicked(MouseEvent evt){
                    button1MouseClicked(evt);
               }
          });

          button1.addKeyListener(new KeyAdapter() {
               @Override
               public void keyReleased(KeyEvent evt){
                    textField1KeyReleased(evt);
               }
          });


Where the methods "button1MouseClicked" and "textField1KeyReleased" are body methods:

        public void button1MouseClicked(MouseEvent evt){
          frame.setTitle(textField1.getText());
     }

     public void textField1KeyReleased(KeyEvent evt){
          button1MouseClicked(null);
     }


I'm loving IntelliJ IDEA and Java ^^, and so... I'm go to learn Java =), no doubt IntelliJ IDEA are the best Java IDE I've tried and I Love IntelliJ IDEA =).

Please sign in to leave a comment.