Since the release of NetBeans 6.0, BeansBinding (JSR 295) framework popularity has increased. Personally I’m using it now in all my projects. Ease of development and the increase of productivity are worth it. The counterpart is that this project looks dead and hasn’t been updated for more than a year now. Even more, recent news about Swing core is not very encouraging. In my opinion I believe that Sun’s budget is very limited and their recent javaFx has consumed all their resources in the past year. Bearing in mind that BeansBinding is now included in netbeans and that javaFx is […]

BeansBinding Performance (Issue 37)

Reading the contents of a file in Java is a very straightforward operation. The java tutorial explains completely how you can find your way to read different types of streams. However when you read an UTF-8 encoded file your fight will start. Most of the UTF-8 and UTF-16 encoded files contain a character at the beginning called BOM (byte-order mark). The BOM consists of a character  (U+FEFF) at the beginning of the stream used to define the byte order and the encoding of the stream. UTF encoded files may or may not contain the BOM. The problem with Java comes when […]

Reading UTF-8 encoded documents in java

Linksys WVC200 11
So you bought an IP camera and would like to store/see images from the camera using java. Recently I bought a couple of IP Cameras for testing purposes. I noticed that each IP camera has different surveillance tools and web interfaces. But most of them have in common that you can access the actual picture by entering an url in your browser. In this post I’ll show you how to see that image and store it using a very simple jav application. The camera I’ll use for the test is a LinkSys WVC200 “Wireless PTZ Internet Camera with Audio”. This […]

Viewing and storing images from an IP Camera

In many cases, web applications give OutOfMemoryError when their threads require high levels of  memory. Image manipulation or intensive database use or calculation can lead to this very common problem. Normally when you get an OutOfMemory error in a desktop application, you can solve this problem by specifying the java commands -Xms*** (initial Java heap size) and -Xmx*** (maximum Java heap size) when running your program. To solve this issue in tomcat, you must specify these options in the tomcat startup command / script / batch. In windows tomcat is installed as a service. Tomcat provides a configuration tool to […]

java.lang.OutOfMemoryError: PermGen space // More memory for Tomcat under windows

In the past 2 entries (Part I and Part II) we learnt how to develop a basic report and how to fill it with data from a database with a jdbc connector. Now we will learn how to call a report from within a Java application and how to set some basic parameters. The most important thing when running your reports from within a java application is to have all the necessary jar libraries available from your classpath. The basic ones for running the sample report will be commons-logging-*.jar, commons-collections-*.jar, jasperrerports-*.jar and yourJDBCconnector.jar. All of them (except the jdbc connector) […]

Getting started with JasperReports // Printing reports from your java ...

This is the second part of a series of articles to get people started with JasperReports. In the second part I’ll explain how to access your database to run simple queries and show them in a very simple report created with iReport. The first thing we need to do to get moving is to have iReport ready. So if you haven’t got it installed do so. Next step is to have the database driver in your iReport library folder. This means that you will need a jdbc jar packaged driver copied to the ./lib/ directory of iReport’s base folder. This […]

Getting started with JasperReports // JDBC connections (Part II)

IReport 1
This is the first of a series of articles to get you started with JasperReports. In first place, JasperReports is one of Java’s reporting engines. It’s very powerful and has lots of features that makes it comparable to commercial reporting solutions such as Crystal Reports. The first thing you need to do to start using this great peace of software is go to the project page and download it (wait). In the project page there is some documentation that will help you getting started. You must know that JasperReports is a reporting engine that integrates many capabilities. Reports are developed […]

Getting started with JasperReports // Reporting in Java (Part I)

IMPORTANT NOTICE This post was published in 2007 and some code was used to interact with databases which had no JDBC connector. It is a very bad practice and unrecommended to send SQL statements directly to a database Such a simple thing as replacing an apostrophe with an escape character from a string sometimes can become a very tedious process, more if you’re using String’s replaceAll(…) function. Replacing apostrophes from Strings may be very useful when creating Statements to pass to an SQL database, preventing SQL injection. Many may say that using PreparedStatements is easier and safer, but in many […]

Replacing Apostrophes from Strings // Cleaning String to pass them ...

Adding a KeyListener to a JTextField to detect KeyPressed events is pretty straightforward. Buy maybe you have encountered some problems when trying to detect special key such as TAB’s. This issue is due to LowLevel keyEvents captured by Swing’s default FocusTraversalKeys. What we need to do to capture the VK_TAB KeyEvent is to remove the default FocusTraversalKeys from the component. [crayon-59ebb7566c57d166205420/] Once we’ve done this with the component, the tab KeyEvent will not be captured by swing’s default focus traversal keys and we will be able to add events normally. [crayon-59ebb7566c588817258292/]

Detecting Tab Key Pressed Event in JTextField ‘s // Event.VK_TAB ...

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-59ebb7566c9c9538028431/]

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-59ebb7566cd12535144601/]

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