List of usage examples for javax.swing JTable getSelectionForeground
public Color getSelectionForeground()
From source file:org.nuclos.client.ui.collect.component.AbstractCollectableComponent.java
public static void setBackgroundColor(Component cellRendererComponent, JTable tbl, Object oValue, boolean bSelected, boolean bHasFocus, int iRow, int iColumn) { cellRendererComponent.setBackground(bSelected ? tbl.getSelectionBackground() : iRow % 2 == 0 ? tbl.getBackground() : NuclosThemeSettings.BACKGROUND_PANEL); cellRendererComponent.setForeground(bSelected ? tbl.getSelectionForeground() : tbl.getForeground()); final TableModel tm; final int adjustColIndex; if (tbl instanceof FixedColumnRowHeader.HeaderTable && ((FixedColumnRowHeader.HeaderTable) tbl).getExternalTable() != null) { tm = ((FixedColumnRowHeader.HeaderTable) tbl).getExternalTable().getModel(); adjustColIndex = FixedRowIndicatorTableModel.ROWMARKERCOLUMN_COUNT; } else {//from ww w . j a v a 2 s . c o m tm = tbl.getModel(); adjustColIndex = 0; } // check whether the data of the component is readable for current user, by asking the security agent of the actual field if (tm instanceof SortableCollectableTableModel<?>) { final SortableCollectableTableModel<Collectable> tblModel = (SortableCollectableTableModel<Collectable>) tm; if (tblModel.getRowCount() > iRow) { final Collectable clct = tblModel.getCollectable(iRow); final Integer iTColumn = tbl.getColumnModel().getColumn(iColumn).getModelIndex() - adjustColIndex; final CollectableEntityField clctef = tblModel.getCollectableEntityField(iTColumn); if (clctef == null) { throw new NullPointerException("getTableCellRendererComponent failed to find field: " + clct + " tm index " + iTColumn); } boolean isEnabled = true; if (!clctef.isNullable() && isNull(oValue)) { cellRendererComponent.setBackground(getMandatoryColor()); cellRendererComponent.setForeground(tbl.getForeground()); } else { // if (clct.getId() == null) { // cellRendererComponent.setBackground(tbl.getBackground()); // cellRendererComponent.setForeground(tbl.getForeground()); // } else { if (tbl instanceof SubForm.SubFormTable) { SubFormTable subformtable = (SubForm.SubFormTable) tbl; Column subformcolumn = subformtable.getSubForm().getColumn(clctef.getName()); if (subformcolumn != null && !subformcolumn.isEnabled()) { isEnabled = false; if (bSelected) { cellRendererComponent .setBackground(NuclosThemeSettings.BACKGROUND_INACTIVESELECTEDCOLUMN); } else { cellRendererComponent.setBackground(NuclosThemeSettings.BACKGROUND_INACTIVECOLUMN); } } } // } try { EntityMetaDataVO meta = MetaDataClientProvider.getInstance() .getEntity(clctef.getEntityName()); if (meta.getRowColorScript() != null && !bSelected) { AbstractCollectableComponent.setBackground(cellRendererComponent, meta.getRowColorScript(), clct, meta, isEnabled); } } catch (CommonFatalException ex) { LOG.warn(ex); } } } } if (tbl instanceof TableRowMouseOverSupport) { TableRowMouseOverSupport trmos = (TableRowMouseOverSupport) tbl; if (trmos.isMouseOverRow(iRow)) { final Color bgColor = LangUtils.defaultIfNull(cellRendererComponent.getBackground(), Color.WHITE); cellRendererComponent .setBackground(new Color(Math.max(0, bgColor.getRed() - (bgColor.getRed() * 8 / 100)), Math.max(0, bgColor.getGreen() - (bgColor.getGreen() * 8 / 100)), Math.max(0, bgColor.getBlue() - (bgColor.getBlue() * 8 / 100)))); // cellRendererComponent.setBackground(UIManager.getColor("Table.selectionBackground")); } } }