PageRenderTime 12ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/rcdkjar/src/org/guha/rcdk/view/table/MyTable.java

http://github.com/rajarshi/cdkr
Java | 60 lines | 27 code | 10 blank | 23 comment | 3 complexity | 6054a941db875fa6ff42f1d0e32d192b MD5 | raw file
  1. package org.guha.rcdk.view.table;
  2. import org.guha.rcdk.util.TablePacker;
  3. import javax.swing.*;
  4. import javax.swing.table.TableModel;
  5. public class MyTable extends JTable {
  6. private TablePacker packer = null;
  7. /**
  8. * Constructs a <code>JTable</code> to display the values in the two dimensional array,
  9. * <code>rowData</code>, with column names, <code>columnNames</code>.
  10. * <code>rowData</code> is an array of rows, so the value of the cell at row 1,
  11. * column 5 can be obtained with the following code:
  12. * <p/>
  13. * <pre> rowData[1][5]; </pre>
  14. * <p/>
  15. * All rows must be of the same length as <code>columnNames</code>.
  16. * <p/>
  17. *
  18. * @param rowData the data for the new table
  19. * @param columnNames names of each column
  20. */
  21. public MyTable(Object[][] rowData, Object[] columnNames) {
  22. super(rowData, columnNames);
  23. }
  24. /**
  25. * Constructs a <code>JTable</code> that is initialized with
  26. * <code>dm</code> as the data model, a default column model,
  27. * and a default selection model.
  28. *
  29. * @param dm the data model for the table
  30. * @see #createDefaultColumnModel
  31. * @see #createDefaultSelectionModel
  32. */
  33. public MyTable(TableModel dm) {
  34. super(dm);
  35. }
  36. public void pack(int rowsIncluded, boolean distributeExtraArea) {
  37. packer = new TablePacker(rowsIncluded, distributeExtraArea);
  38. if (isShowing()) {
  39. packer.pack(this);
  40. packer = null;
  41. }
  42. }
  43. public void addNotify() {
  44. super.addNotify();
  45. if (packer != null) {
  46. packer.pack(this);
  47. packer = null;
  48. }
  49. }
  50. }