コード例 #1
0
  // Initialize JTable
  private void initTable() {
    DialogTableModel tblModel = new DialogTableModel(students);
    studentsTbl.setModel(tblModel);

    studentsTbl.setAutoCreateRowSorter(true);
    studentsTbl.setRowSelectionAllowed(true);
    studentsTbl.getRowSorter().toggleSortOrder(1);
    studentsTbl.setGridColor(Color.gray);
    studentsTbl.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    studentsTbl.setRowHeight(22);

    TableColumn tc = studentsTbl.getColumnModel().getColumn(0);
    tc.setCellEditor(studentsTbl.getDefaultEditor(Boolean.class));
    tc.setCellRenderer(studentsTbl.getDefaultRenderer(Boolean.class));
    tc.setHeaderRenderer(
        new CheckBoxTableHeader(
            new ItemListener() {
              @Override
              public void itemStateChanged(ItemEvent e) {
                Object source = e.getSource();
                if (source instanceof AbstractButton == false) {
                  return;
                }
                boolean checked = e.getStateChange() == ItemEvent.SELECTED;
                for (int x = 0, y = studentsTbl.getRowCount(); x < y; x++) {
                  studentsTbl.setValueAt(new Boolean(checked), x, 0);
                }
              }
            }));
  }
コード例 #2
0
  public MenuItemExplorer() {
    tableModel = new BeanTableModel<MenuItem>(MenuItem.class);
    tableModel.addColumn(POSConstants.ID.toUpperCase(), "id"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.NAME.toUpperCase(), "name"); // $NON-NLS-1$
    tableModel.addColumn(
        POSConstants.TRANSLATED_NAME.toUpperCase(), "translatedName"); // $NON-NLS-1$
    tableModel.addColumn(
        POSConstants.PRICE.toUpperCase() + " (" + Application.getCurrencySymbol() + ")",
        "price"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    tableModel.addColumn(POSConstants.VISIBLE.toUpperCase(), "visible"); // $NON-NLS-1$
    tableModel.addColumn(
        POSConstants.DISCOUNT.toUpperCase() + "(%)", "discountRate"); // $NON-NLS-1$ //$NON-NLS-2$
    tableModel.addColumn(POSConstants.FOOD_GROUP.toUpperCase(), "parent"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.TAX.toUpperCase(), "tax"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.SORT_ORDER.toUpperCase(), "sortOrder"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.BUTTON_COLOR.toUpperCase(), "buttonColor"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.TEXT_COLOR.toUpperCase(), "textColor"); // $NON-NLS-1$
    tableModel.addColumn(POSConstants.IMAGE.toUpperCase(), "imageData"); // $NON-NLS-1$

    tableModel.addRows(MenuItemDAO.getInstance().findAll());

    table = new JXTable(tableModel);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setRowHeight(30);

    table.setDefaultRenderer(Object.class, new CustomCellRenderer());
    table
        .getColumnModel()
        .getColumn(10)
        .setCellRenderer(
            new DefaultTableCellRenderer() {
              @Override
              public Component getTableCellRendererComponent(
                  JTable table,
                  Object value,
                  boolean isSelected,
                  boolean hasFocus,
                  int row,
                  int column) {
                if (value instanceof Color) {
                  JLabel lblColor = new JLabel("TEXT COLOR", JLabel.CENTER);
                  lblColor.setForeground((Color) value);
                  return lblColor;
                }
                return super.getTableCellRendererComponent(
                    table, value, isSelected, hasFocus, row, column);
              }
            });

    setLayout(new BorderLayout(5, 5));
    add(new JScrollPane(table));

    add(createButtonPanel(), BorderLayout.SOUTH);
    add(buildSearchForm(), BorderLayout.NORTH);
  }
コード例 #3
0
  /**
   * Lager tabell for avregningimport
   *
   * @return tabell
   */
  public JXTable getTableImport() {
    table = new JXTable();

    table.setModel(new DeductImportTableModel(deductImportSelectionList));
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setSelectionModel(
        new SingleListSelectionAdapter(deductImportSelectionList.getSelectionIndexHolder()));
    table.setColumnControlVisible(true);
    deductImportSelectionList.clearSelection();

    table.packAll();
    table.setSortable(true);
    return table;
  }
コード例 #4
0
ファイル: ReconcilViewHandler.java プロジェクト: abrekka/fraf
  /**
   * Lager tabell for rapport
   *
   * @return tabell
   */
  public JXTable getTableReport() {
    table = new JXTable();

    tableModel = new ReconcilTableModel(reportSelectionList);
    table.setModel(tableModel);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setColumnControlVisible(true);
    table.setSearchable(null);

    table.setDragEnabled(false);

    table.setShowGrid(true);
    table.packAll();
    return table;
  }