SWING / CATATAN</>↗Swing19 Sep 2010
Each column of a JTable component is represented by the TableColumn class. The method for setting or changing the width of the column includes the setMinWidth(), setMaxWidth() and setPreferredWidth(). These methods are used to set the minimum, maximum and the preferred width of the column respectively. When we set only the preferred width of a […]
SWING / CATATAN</>↗Swing19 Sep 2010
Another way to create and configure a JTable component is using a table model. A table model is more preferred to using array or vector as the data source for the table. The simplest way to create a table model is by extending the AbstractTableModel abstract class which implements the TableModel interface. The AbstractTableModel implements […]
SWING / CATATAN</>↗Swing18 Sep 2010
The code snippet presented below shows you how to create a simple JTable component in a swing application. To create a JTable component we initialize it using the constructor that accept two parameters. The first parameter is the table’s row of data which type is Object[][], a two-dimensional array of Object. The second parameter is […]
CORE API / CATATAN</>↗Core API18 Sep 2010
This example show you how to use the BreakIterator.getSentenceInstance() to breaks a paragraphs into sentences that composes the paragraph. To get the BreakIterator instance we call the getSentenceInstance() factory method and passes a locale information. In the count(BreakIterator bi, String source) method we iterate the break to extract sentences that composes the paragraph which value […]
CORE API / CATATAN</>↗Core API15 Sep 2010
At first, it might look simple. We can just split the text using the String.split(), the word is split using space. But what if a word ends with questions marks (?) or exclamation marks (!) instead? There might be some other rules that we also need to care. Using the java.text.BreakIterator makes it much simpler. […]
CORE API / CATATAN</>↗Core API12 Sep 2010
When the strings must be compared multiple times, for example when sorting a list of strings. It’s more efficient to use CollationKey class. Using CollationKey to compare strings is generally faster than using Collator.compare(). You can not create CollationKey directly. Rather, generate them by calling Collator.getCollationKey() method. You can only compare CollationKey generated from the […]