[Android] Parsing JSON with JsonReader

Back in Parsing JSON with JSONObject, I covered parsing JSON using JSONObject, where the object is created after reading the entire data into a String. Here, the same application will be created, but it will JsonReader instead. The source code for the demo can be downloaded from the Github repository.
Read more of this post


[Android] Allowing the user to enter a filter for a ListView

Back in Using an ArrayAdapter to Control a ListView’s Data, I wrote about filtering a ListView using its setTextFilterEnabled method. One of the comments reminded me that that not all devices have a physical keyboard and the virtual keyboard does not always show when entering the filter. For devices that do not have a physical keyboard, you could ask the InputMethodManager to display the virtual keyboard:

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(getListView(), 0);

Read more of this post

[Java] Setting the Window Title Font with the Substance Look and Feel

Fonts for various aspects of the UI is usually by putting the font as a default property in UIManager or UIDefaults. However, there doesn’t seem to be one for the window title. If you were using the Substance look and feel, SubstanceLookAndFeel provides the setFontPolicy(FontPolicy fontPolicy) method. By controlling FontPolicy, you will be able to control the font used for the window title.
Read more of this post

[Android] Parsing JSON with JSONObject

Android provides JSONObject and JsonReader for parsing JSON. JSONObject has been around since API level 1 (the first Android release), whereas JsonReader has been around only since API level 11 (Android 3). Here, we’ll look at using JSONObject using a demo.

Read more of this post

[Android] Downloading and Displaying RSS Content

RSS feeds list the latest content added to a site. The sample in this post demonstrates how to obtain RSS content and display the latest item. It will cover:

The sample code can be downloaded from the GitHub repository.

Read more of this post

[Java] Specifying the column widths of a JTable as percentages

The widths of the columns of a JTable are specified through TableColumn.setWidth. To set the widths of the columns as percentage, set the widths of column in proportion to each other. For example:

Read more of this post

[Java] Getting Combo Box Renderers to Look Consistent with Other Combo Boxes

One way of controlling the text in a JComboBox is to provide a custom ListCellRenderer. I have seen implementations that subclass a concrete implementation (such as DefaultListCellRenderer or the BasicComboBoxRenderer). Generally though, I find that the combo boxes using such renderers can appear inconsistent with another combo box that may not have a renderer set or one that extends a different implementation. To illustrate the inconsistency that could happen, I prepared a small test program that you can download from my Github repository. It displays a number of combo boxes that are based on different renderers. Just running it produces the following dialog in Windows 7:

Read more of this post