How do I get a JScrollPane to always display scroll bars?
You can achieve this by setting the scroll bar policy on both the verical and horizontal scroll bars.
Read MoreYou can achieve this by setting the scroll bar policy on both the verical and horizontal scroll bars.
Read MorePrior to Java 7, Java did not provide a standard method to copy a file. To implement copying you needed to read all bytes from source file and write to destination. The read() method will return -1 when eof is reached, otherwise it returns the number of bytes read.
Read MoreWe often get asked about how to implement a list of checkboxes using Swing. Using a JList filled with JCheckbox’s seems the obvious solution, however JList does not support cell editors so this does not work. One possible solutions is to use a single column JTable and store boolean’s as the cell value (the default…
Read MoreThe Integer class has a number of static methods for parsing strings. For the case where we want to check if if a string contains a valid integer we can use the method Integer.parseInt() and catch the exception that is thrown when the number cannot be parsed.
Read MoreOften you need to read a file line by line. Alternatively sometimes you want to read text word by word (for example to count the occurrence of different words). The Scanner classes next() method can be used for this as shown in the following example. You can find an example of the use of the…
Read MoreIf you do not want to store your log4j configuration in your classes directory then you need to tell log4j where it can find it. One possibility is to configure it in your applicationContext.xml as shown here If you are running your web application as an expanded war then another option is to use a…
Read MoreThe readLine() method of java.io.BufferedReader class reads the next line from a text file. When it reaches the end of the file it will return null.
Read More