How To Automatically Switch a Toggle Button


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


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) {