Showing posts with label Java Swings. Show all posts
Showing posts with label Java Swings. Show all posts

08 February, 2010

Adding Custom Filter to JFileChooser in Java

JFile chooser doesn't filter any file types. It displays all types of files in the File Chooser dialog. It is the developer responsibility to extend the FileFilter class to filter particular type of file.

02 February, 2010

How to mask password field in Java?


Login windows use password masking as a technique to either hide the password as it is being typed or displaying a character (such as an asterisk '*') instead of the characters that users type. For example, when you login on a Windows machine, you are presented with a login dialog box in which the password field uses an asterisk as the masking or echo character.
If you wish to provide a graphical login dialog box for your application, you can use the JPasswordField, which allows the editing of a single line of text where the view indicates something was typed, but does not show the original characters. If you use the JPasswordField, the default echo character is an asterisk '*', but you can change it to any character of your choice. Again, if you set the echo character to zero, 0, it means that characters will be displayed as they are typed and no masking will be performed. 

example snippet of code:

JPasswordField password = new JPasswordField(8);
password.setEchoChar('#');

30 January, 2010

How to Export JTable data into Excel Sheet?

Some times it is required to generate report based on the data in the JTable. In that case the POI-HSSF API to access Microsoft Excel document is very  much useful to generate Excel file using the content of JTable.