1 | // Jomic - a viewer for comic book archives. |
2 | // Copyright (C) 2004-2011 Thomas Aglassinger |
3 | // |
4 | // This program is free software: you can redistribute it and/or modify |
5 | // it under the terms of the GNU General Public License as published by |
6 | // the Free Software Foundation, either version 3 of the License, or |
7 | // (at your option) any later version. |
8 | // |
9 | // This program is distributed in the hope that it will be useful, |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | // GNU General Public License for more details. |
13 | // |
14 | // You should have received a copy of the GNU General Public License |
15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | package net.sf.jomic.comic; |
17 | |
18 | import java.awt.Component; |
19 | |
20 | import javax.swing.BorderFactory; |
21 | import javax.swing.JTable; |
22 | import javax.swing.JTextField; |
23 | import javax.swing.table.TableCellRenderer; |
24 | |
25 | import net.sf.jomic.tools.ErrorTools; |
26 | |
27 | /** |
28 | * TableCellRenderer for errors in comic images. |
29 | * |
30 | * @author Thomas Aglassinger |
31 | */ |
32 | public class ComicImageErrorRenderer extends JTextField implements TableCellRenderer |
33 | { |
34 | private ErrorTools errorTools; |
35 | |
36 | public ComicImageErrorRenderer() { |
37 | errorTools = ErrorTools.instance(); |
38 | setOpaque(true); |
39 | //MUST do this for background to show up. |
40 | setBorder(BorderFactory.createEmptyBorder()); |
41 | } |
42 | |
43 | public Component getTableCellRendererComponent( |
44 | final JTable table, |
45 | final Object errorObject, |
46 | final boolean isSelected, |
47 | final boolean hasFocus, |
48 | final int row, |
49 | final int column) { |
50 | if (errorObject != null) { |
51 | // TODO: setBackground(new Color(240, 216, 216)); |
52 | Throwable error = (Throwable) errorObject; |
53 | |
54 | setText(error.getMessage()); |
55 | setToolTipText(errorTools.getStackTrace(error)); |
56 | } else { |
57 | // TODO: setBackground(<default>); |
58 | setText(""); |
59 | setToolTipText(null); |
60 | } |
61 | return this; |
62 | } |
63 | } |