r3369 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor
Author: echatellier Date: 2012-04-13 17:26:32 +0200 (Fri, 13 Apr 2012) New Revision: 3369 Url: http://chorem.org/repositories/revision/lima/3369 Log: Add documentation. Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java 2012-04-13 14:56:37 UTC (rev 3368) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java 2012-04-13 15:26:32 UTC (rev 3369) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2008 - 2011 CodeLutin + * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -24,23 +24,43 @@ */ package org.chorem.lima.ui.celleditor; -import sun.swing.DefaultLookup; +import java.awt.Color; +import java.awt.Component; import javax.swing.JLabel; import javax.swing.JTable; +import javax.swing.UIManager; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; import javax.swing.table.DefaultTableCellRenderer; -import java.awt.Color; -import java.awt.Component; -@SuppressWarnings("restriction") +/** + * Renderer qui affiche la valeur de la cellule (toString()) en permettant de + * conserver les cases rouges (entre invalides) meme lors de la selection + * de la ligne. + * + * TODO echatellier 20120412 reprise de code herité du jdk, pas très propre + * mais en essayant de l'enlevr, on perd le coloration des lignes non + * selectionnées. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ public class EmptyCellRenderer extends DefaultTableCellRenderer { + /** serialVersionUID. */ private static final long serialVersionUID = -7834417406160620726L; + public EmptyCellRenderer() { + + } + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + //Create a new JLabel to avoid colouring only when row is selected JLabel mycell = new JLabel(); mycell.setOpaque(true); @@ -57,10 +77,10 @@ if (hasFocus) { Border border = null; if (isSelected) { - border = DefaultLookup.getBorder(this, ui, "Table.focusSelectedCellHighlightBorder"); + border = UIManager.getBorder("Table.focusSelectedCellHighlightBorder"); } if (border == null) { - border = DefaultLookup.getBorder(this, ui, "Table.focusCellHighlightBorder"); + border = UIManager.getBorder("Table.focusCellHighlightBorder"); } mycell.setBorder(border); } @@ -70,7 +90,7 @@ // if empty or null, colour background in red // else setText if (value instanceof String) { - if (String.valueOf(value).isEmpty() || String.valueOf(value) == null) { + if (String.valueOf(value) == null || String.valueOf(value).isEmpty()) { mycell.setBackground(new Color(255, 198, 209)); } else { mycell.setText(value.toString());
participants (1)
-
echatellier@users.chorem.org