def _prepare_cell_renderers(self): default_cell_renderer = DefaultTableCellRenderer() default_cell_renderer.setHorizontalAlignment(JLabel.LEFT) for column_name, column in self._get_columns(): cell_renderer = self._create_cell_renderer(column_name) if cell_renderer is None: cell_renderer = default_cell_renderer column.setCellRenderer(cell_renderer)
def getCellRenderer(self, row, column): import javax.swing.table.DefaultTableCellRenderer as DefaultTableCellRenderer import javax.swing.JLabel as JLabel global AAA renderer = None if AAA.columnTypes[column]=="Text": renderer = DefaultTableCellRenderer() renderer.setHorizontalAlignment(JLabel.LEFT) elif AAA.columnTypes[column]=="Currency2" or AAA.columnTypes[column]=="Currency0": rowCurrencies = self.getDataModel().getRowCurrencies() curr = None if 0 <= row and row < len(rowCurrencies): curr = AAA.rowCurrencies.get(row) else: curr = self.book.getCurrencies().getBaseType() # Footer reports base currency renderer = AAA.CurrencyRenderer(curr, AAA.columnTypes[column] == "Currency0") renderer.setHorizontalAlignment(JLabel.RIGHT) elif AAA.columnTypes[column]=="Percent": renderer = AAA.PercentRenderer() renderer.setHorizontalAlignment(JLabel.RIGHT) else: renderer = DefaultTableCellRenderer() return renderer