How To Automatically Switch a Toggle Button

advertisements

How to make a toggle button toggled automatically when someone types anything in text field?? i am using java Net-beans


      jToggleButton1.setSelected(true);

and if you are using netbeans go to properties of button and choose selected property mark it checked if you want someone to enter the text in the textfield then automatically let the toggle button select use like this

    private void jTextField1KeyPressed(java.awt.event.KeyEvent evt) {
     jToggleButton1.setSelected(true);
    }