Monthly Archives: May 2007


customerIcon
Internet offers many opportunities and possibilities for developers with imagination. Today, most search engines and specialized sites count with API’s to access their data from other software, sites, devices… Today I’m going to show you a dirty example of how this apis can benefit your program. In less of ten lines of code (someone intelligent would have done it in less) I will add an Icon to a jButton with an image stored in the net. To do this I will use yahoo’s Image Search API, documentation can be found here. For demonstration purposes I will use the YahooDemo applicationId, […]

Dynamic icons for your JComponents // Create an icon JButton ...


2
When working with tables, it may be useful to detect selection changes. If for example, you need to sum the values of a specified column in a selection range, this method will be most essential. If you explore the available methods to add listeners to a JTable, you will notice there’s no such thing as a selectionListener. This is because the JTable has its own selection model, where you can add the listener. The following code illustrates the way to go to add a selection listener: [crayon-59ebb6701043f847248025/]

JTable, detecting selection changes // ListSelectionListener /*Selection Changed ...


When developing user interfaces for management software you usually need to check what the user inputs in order to store the values in a database or a file. Java offers different alternatives to parse a String (normally the way user inputs values to the system) to other data types. The class SimpleDateFormat from the package java.text offers a simple method to do this. You just have to call parse(String youDate) in order to get a java.util.Date. Following you can find some code which explains this method and some of its particularities: [crayon-59ebb670106d1956780904/]

SimpleDateFormat to check user date input // parsing String to ...



When printing reports or casting Strings to Numbers, it’s very useful to use the DecimalFormat class found in java.text. This class is pretty straightforward and easy to use, but some problems may be found when your work with this class in computers from other countries. Internationalization will cause your program to behave in a way you may not expect in some cases. If you use this class to parse a number to a String, you may find that when a user enters a number in a french computer you will be getting a ParseException, because the computer is expecting different symbols. […]

Numbers to Strings with custom symbols // DecimalFormat – DecimalFormatSymbols