[Schmitzm-commits] r1891 - trunk/schmitzm-core/src/main/java/de/schmitzm/swing
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Thu Mar 8 15:35:54 CET 2012
Author: mojays
Date: 2012-03-08 15:35:54 +0100 (Thu, 08 Mar 2012)
New Revision: 1891
Modified:
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SelectableJTable.java
Log:
SelectableJTable: enable/disable alternating column backgrounds (default: disabled) to avoid conflicts with background set by cell renderer!
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SelectableJTable.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SelectableJTable.java 2012-03-08 09:43:58 UTC (rev 1890)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SelectableJTable.java 2012-03-08 14:35:54 UTC (rev 1891)
@@ -60,6 +60,8 @@
protected Color columnBackgroundDefault = SwingUtil.getDefaultBackground(this);
/** Column background for alternating columns (index 1, 3, 5, ...). */
protected Color columnBackgroundGreyed = null;
+ /** Indicates whether alternating column background is enabled (Default: {@code false}). */
+ protected boolean greyedBackgroundEnabled = false;
/**
@@ -194,8 +196,9 @@
public Component prepareRenderer(final TableCellRenderer renderer, final int row, final int column) {
final Component prepareRenderer = super.prepareRenderer(renderer, row, column);
// set column background for cell
- if ( !isCellSelected(row, column) )
+ if ( isAlternatingColumnBackgroundEnabled() && !isCellSelected(row, column) ) {
prepareRenderer.setBackground( getColumnBackground(column) );
+ }
if ( !hasAutoGrowColumns() )
return prepareRenderer;
@@ -263,4 +266,18 @@
public Color getAlternatingColumnBackground() {
return this.columnBackgroundGreyed;
}
+
+ /**
+ * Returns whether alternating column background is enabled.
+ */
+ public boolean isAlternatingColumnBackgroundEnabled() {
+ return this.greyedBackgroundEnabled;
+ }
+
+ /**
+ * Sets whether alternating column background is enabled.
+ */
+ public void setAlternatingColumnBackgroundEnabled(boolean enabled) {
+ this.greyedBackgroundEnabled = enabled;
+ }
}
More information about the Schmitzm-commits
mailing list