Upper Case JTextField in Swing: Ready made code

Sunday 27 July 2008 @ 2:23 am

    Here’s a ready made Upper case text field written as a swing component. It converts all characters entered in it automatically to upper case before inserting into it’s own document. So the when the user types in this text field he will see only characters in upper case irrespective of the case with which he types. There is no limitation to use this code. Use it in whatever way you like.

Continue Reading »
Upper Case JTextField in Swing: Ready made code





Max Length on JTextField Using DocumentFilter: A Step by Step tutorial

Wednesday 23 July 2008 @ 6:30 pm

  Have you ever tried to make a textfield that accepts only 20 characters? Or a text area that automatically converts the user typed letters to upper case? Swing’s Document Listener is the most accurate and hassle-free way to achieve this in Swing. This articles explains you what you need to get started with Document Filter. Step by Step.

Continue Reading »
Max Length on JTextField Using DocumentFilter: A Step by Step tutorial





Swing’s InputVerifier tutorial: A super elegant way for validation

Friday 4 July 2008 @ 5:07 am

Let’s consider a common coding situation. Suppose you have a text field in your form that accepts an email address. Suppose you need to code such that if the email address typed by the user is not valid, then you shouldn’t let the focus out of this textfield. Where would you put such a code? In the focus lost of the email-text-field? In the focus gained for all other text-fields? I don’t know what’s the best way to do this in JavaScript but there’s a super-elegant way in Swing!





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





Using SwingWorker - A Step by Step tutorial

Friday 27 June 2008 @ 3:07 pm

SwingWorker is one of the most handiest utility classes provided in Swing. Most of the interviews on Swing have a question or two on this class. Let’s make sure you know all about it’s need and usage. Step by Step.

Continue Reading »
Using SwingWorker - A Step by Step tutorial









Popular Articles

Blog Categories

Monthly Archives

Resources