summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'dozentenmodul/src/main/java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ListTable.java36
1 files changed, 20 insertions, 16 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ListTable.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ListTable.java
index cd1ed7b5..8ac6441d 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ListTable.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ListTable.java
@@ -1,7 +1,6 @@
package org.openslx.dozmod.gui.control.table;
import java.awt.Component;
-import java.awt.Font;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -74,7 +73,8 @@ public abstract class ListTable<T> extends JTable {
this.setRowSelectionAllowed(true);
this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
this.setRowHeight(this.getRowHeight() * Config.getFontScaling() / 100);
-
+ this.setOpaque(false);
+
sorter.addRowSorterListener(new RowSorterListener() {
@Override
public void sorterChanged(RowSorterEvent e) {
@@ -105,14 +105,14 @@ public abstract class ListTable<T> extends JTable {
}
return itemList;
}
-
+
public T getSelectedItem() {
int rowIndex = getSelectedRow();
if (rowIndex == -1)
return null;
return getViewRow(rowIndex);
}
-
+
public List<T> getData() {
if (model.data == null)
return null;
@@ -196,11 +196,11 @@ public abstract class ListTable<T> extends JTable {
* Called when rendering a column is being prepared. This is a good time to
* change the color or font for the given cell.
*
- * @param component The component representing the cell being rendered
- * @param row item of the row being rendered
+ * @param component The component representing the cell being rendered
+ * @param row item of the row being rendered
* @param listTableColumn column (model-based) of the cell being rendered
- * @param isSelected whether the row is currently selected
- * @return
+ * @param isSelected whether the row is currently selected
+ * @return
*/
public Component prepareRenderHook(Component component, T row, ListTableColumn listTableColumn,
boolean isSelected) {
@@ -213,7 +213,7 @@ public abstract class ListTable<T> extends JTable {
* displayable item. By default this is the identity function, returning the
* value as-is.
*
- * @param value Value to render
+ * @param value Value to render
* @param column Column index (model-based) being rendered
* @return Rendered version of value. This should match the column class
*/
@@ -226,7 +226,8 @@ public abstract class ListTable<T> extends JTable {
Component c = super.prepareRenderer(renderer, row, column);
T item = getViewRow(row);
if (c != null && item != null) {
- c = prepareRenderHook(c, item, model.getColumn(convertColumnIndexToModel(column)), isRowSelected(row));
+ c = prepareRenderHook(c, item, model.getColumn(convertColumnIndexToModel(column)),
+ isRowSelected(row));
}
return c;
}
@@ -279,12 +280,12 @@ public abstract class ListTable<T> extends JTable {
break;
}
}
-
+
@Override
public boolean isCellEditable(int row, int col) {
return columns[col].column.isEditable;
}
-
+
@Override
public void setValueAt(Object aValue, int row, int col) {
if (isCellEditable(row, col)) {
@@ -323,7 +324,7 @@ public abstract class ListTable<T> extends JTable {
return null;
return table.getValueAtInternal(item, columns[columnIndex].column);
}
-
+
public T getModelRow(int rowIndex) {
return table.getModelRow(rowIndex);
}
@@ -358,6 +359,8 @@ public abstract class ListTable<T> extends JTable {
value = modelValueToDisplayFormat(value, model.getColumn(convertColumnIndexToModel(column)));
}
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ // If selected the row should be opaque. Otherwise the selection background is not shown.
+ setOpaque(isSelected);
setBorder(null);
return this;
}
@@ -371,7 +374,7 @@ public abstract class ListTable<T> extends JTable {
if (value != null) {
value = modelValueToDisplayFormat(value, model.getColumn(convertColumnIndexToModel(column)));
}
- setIcon((Icon)value);
+ setIcon((Icon) value);
return this;
}
}
@@ -393,8 +396,9 @@ public abstract class ListTable<T> extends JTable {
public ListTableColumn(String colName, Class<?> colClass, Comparator<?> sortComparator) {
this(colName, colClass, sortComparator, false);
}
-
- public ListTableColumn(String colName, Class<?> colClass, Comparator<?> sortComparator, boolean isEditable) {
+
+ public ListTableColumn(String colName, Class<?> colClass, Comparator<?> sortComparator,
+ boolean isEditable) {
this.isEditable = isEditable;
this.colName = colName;
this.colClass = colClass;