KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sellwin > gui > DescRenderer


1 package sellwin.gui;
2
3 import sellwin.utils.*;
4
5 import java.awt.*;
6 import java.util.*;
7 import javax.swing.*;
8 import javax.swing.event.*;
9 import javax.swing.table.*;
10
11 // SellWin http://sourceforge.net/projects/sellwincrm
12
//Contact support@open-app.com for commercial help with SellWin
13
//This software is provided "AS IS", without a warranty of any kind.
14

15 /**
16  * This class implements a description renderer for the
17  * activity table to display a really long string in a table
18  */

19 public class DescRenderer extends JLabel implements TableCellRenderer {
20
21     private String JavaDoc currentDesc;
22
23     /**
24      * construct a desc renderer
25      */

26     public DescRenderer() {
27         super();
28         setBackground(MainWindow.LETTERS);
29         setFont(MainWindow.FIELD_FONT);
30     }
31
32     /**
33      * part of the java interface spec
34      */

35     public final Component getTableCellRendererComponent(
36         JTable table, Object JavaDoc value,
37         boolean isSelected, boolean hasFocus,
38         int row, int col) {
39
40         if (value == null)
41             currentDesc = new String JavaDoc("");
42         else
43             currentDesc = (String JavaDoc)value;
44
45         setText(currentDesc);
46         return this;
47     }
48
49
50     /**
51      * get the desc used by this renderer
52      * @return the desc being used
53      */

54     public final String JavaDoc getDesc() {
55         return currentDesc;
56     }
57
58     /**
59      * set the label's text using the object (desc)
60      * @param value the object we are to render
61      */

62     public final void setValue(Object JavaDoc value) {
63         if (value == null)
64             currentDesc = new String JavaDoc("");
65         else {
66             currentDesc = (String JavaDoc)value;
67         }
68
69
70         setText(currentDesc);
71     }
72 }
73
Popular Tags