Archive for the 'buttons' Category



Setting the Default Button in Swing

Thursday 3 July 2008 @ 7:13 pm

Consider you have a form with several text fields and some buttons. One of the buttons is usually the “default” button , which would get executed if the user pressed enter, while the focus is in any of the text fields in that form. You should have definitely seen this type of buttons. As an example in google.com, you can type you query in the textfield and press enter, which is same as clicking the “Google Search” button.
  While most people who implement this, add a keylistener to each textfield and execute the doClick() method in JButton when the Enter key is pressed, there is an easier way. Also by implementing this by setting up the listener, you will not be able to tell swing to let it do OS level special effects like the “pulsing” effect in a MAC or a border-effect on windows.
Continue Reading »
Setting the Default Button in Swing








Popular Articles

Blog Categories

Monthly Archives

Resources