Wednesday, July 17, 2013

012. FILTER (JTABLE PART 3)



Requirements (we have read):
- re-download daniani.jar (for newer version)
- 008. Add Database to JTable (JTable Part 1)
- 006. Container: JSplitPane by Netbeans

  1. Open a project that we have made in 008. Add Database to JTable (JTable Part 1) and do a modification.
  2. Add container JSplitpane.
  3. Set orientation property = VERTICAL SPLIT
  4. Set dividerLocation = 30
  5. Add container JPanel, and  put on Top JSplitpane.
  6. Set JPanel layout = Box Layout
  7. Move table to Bottom JSplitpane.
    If TopSplitpane disappear, then resize the dividerLocation, for example to 31.
  8. Add JTextField (have to) to JPanel, named=txSearch, set horizontalAlignment = CENTER, set Text property to be empty.
  9. Add JLabel (optional) named=lbRowCount, and put on the right of JTextField. set horizontalAlignment = CENTER, maximumSize = [50, 30], minimumSize = [50, 30], preferredSize = [50, 30]
  10. The design will look like:
  11. Go to source code, and add script below dtble.buildtable(...) :
    dtble.tableFilter(txSearch, lbRowCount);
    We can set null for JLabel, example: dtble.tableFilter(txSearch, null);
  12. Try it by type some character in txSearch. It will filter for all column.
  13. What about filtering per-column?
    Just click the button inside txSearch.
  14. Click a row on certain column, then right click.
  15. Try to add criteria by click on the other column, then right click.
  16. To display the criteria that we have made, doubleclick the txSearch.
  17. Click the button to switch to all column mode.
Note:
For boolean class-type, we can set criteria = true or false

I hope it work..