Пример #1
0
  public void refresh() {
    Iterable<Property> properties = Collections.emptyList();

    if (beanHelper != null) {
      Image icon = beanHelper.getIcon(BeanInfo.ICON_COLOR_32x32);
      if (icon == null) {
        remove(top);
      } else {
        JXImageView logo = new JXImageView();
        logo.setImage(icon);
        add(logo, BorderLayout.NORTH);
      }
      properties =
          filter(
              beanHelper.getProperties(),
              new Predicate<Property>() {
                @Override
                public boolean apply(Property input) {
                  return !input.isHidden();
                }
              });
    }

    table.setModel(new MyTableModel(properties));

    // should we expose minimum row/column sizes as a user property?
    table.setRowHeight(18); // essentially the minimum row height
    table.getColumnModel().getColumn(0).setMinWidth(1);
    table.getColumnModel().getColumn(0).setMaxWidth(1);
    table.getColumnModel().getColumn(1).setMinWidth(1);

    table.packAll();
    revalidate();
  }
  // 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);
                }
              }
            }));
  }
Пример #3
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);
  }
 private void init_tbl_branch_locations() {
   tbl_branch_locations_ALM = new ArrayListModel();
   tbl_branch_locations_M = new Tblbranch_locationsModel(tbl_branch_locations_ALM);
   tbl_branch_locations.getTableHeader().setPreferredSize(new Dimension(100, 40));
   tbl_branch_locations.setModel(tbl_branch_locations_M);
   tbl_branch_locations.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
   tbl_branch_locations.setRowHeight(25);
   int[] tbl_widths_branch_locations = {200, 200, 70, 0, 0, 0};
   for (int i = 0, n = tbl_widths_branch_locations.length; i < n; i++) {
     if (i == 0) {
       continue;
     }
     TableWidthUtilities.setColumnWidth(tbl_branch_locations, i, tbl_widths_branch_locations[i]);
   }
   Dimension d = tbl_branch_locations.getTableHeader().getPreferredSize();
   d.height = 25;
   tbl_branch_locations.getTableHeader().setPreferredSize(d);
   tbl_branch_locations.getTableHeader().setFont(new java.awt.Font("Arial", 0, 11));
   tbl_branch_locations.setRowHeight(25);
   tbl_branch_locations.setFont(new java.awt.Font("Arial", 0, 11));
 }
Пример #5
0
  public JXTable createConfigureDecadeDetailsTable(LinkTableModel model) {
    JXTable table = new JXTable();
    table.setCellSelectionEnabled(true);
    table.setFont(monthView.getFont());
    table.setShowGrid(false, false);
    table.setTableHeader(null);

    table.setDefaultRenderer(
        Date.class, createDateRenderer(model.selectAction, monthPaddingBorder, JLabel.CENTER));
    table.setHighlighters(createCurrentDateHighlighters());
    table.setModel(model);
    Component comp = table.prepareRenderer(table.getCellRenderer(1, 1), 1, 1);
    table.setRowHeight(comp.getPreferredSize().height);

    return table;
  }
Пример #6
0
  public JXTable createConfigureMonthDetailsTable(LinkTableModel dateTableModel) {

    JXTable table = new JXTable();
    table.setCellSelectionEnabled(true);
    table.setVisibleRowCount(6);
    table.setFont(monthView.getFont());
    table.setShowGrid(false, false);

    configureDayOfWeeksHeader(table);
    table.setDefaultRenderer(
        Date.class,
        createDateRenderer(dateTableModel.selectAction, paddingBoxBorder, JLabel.TRAILING));

    table.setHighlighters(createCurrentDateHighlighters());
    table.setModel(dateTableModel);
    table.packAll();
    Component comp = table.prepareRenderer(table.getCellRenderer(1, 1), 1, 1);
    table.setRowHeight(comp.getPreferredSize().height);

    return table;
  }