01: package xui.samples.carousel.components;
02:
03: import com.xoetrope.swing.XTreeTable;
04: import java.awt.Color;
05: import javax.swing.event.ListSelectionEvent;
06: import javax.swing.event.ListSelectionListener;
07: import net.xoetrope.swing.XLabel;
08: import net.xoetrope.xui.*;
09: import net.xoetrope.xui.data.XModel;
10:
11: /**
12: * A reponse class for this page
13: * <p>Copyright: Xoetrope Ltd. (c) 2001-2006</p>
14: * <p>License: see license.txt</p>
15: * <p>$Revision: 1.6 $</p>
16: */
17: public class Tables extends XPage implements ListSelectionListener {
18: private XTreeTable attributeTable;
19: private XLabel description;
20:
21: public Tables() {
22: }
23:
24: public void pageCreated() {
25: attributeTable = (XTreeTable) findComponent("resultsTable");
26: description = (XLabel) findComponent("description");
27:
28: // Configure the results table
29: attributeTable.setAltUnselectedColors(attributeTable
30: .getForeground(), new Color(242, 246, 255));
31: attributeTable
32: .setAutoResizeMode(XTreeTable.AUTO_RESIZE_LAST_COLUMN);
33:
34: attributeTable.getSelectionModel().removeListSelectionListener(
35: this );
36: attributeTable.getSelectionModel().addListSelectionListener(
37: this );
38: }
39:
40: /**
41: * The table selection has changed
42: */
43: public void valueChanged(ListSelectionEvent lse) {
44: if (!lse.getValueIsAdjusting()) {
45: int selectedRow = attributeTable.getSelectedRow();
46: if (selectedRow > -1) {
47: String fieldValue = (String) attributeTable.getValue(
48: selectedRow, 3);
49: // Show the text/value as html
50: description.setText(translate("<html>" + fieldValue
51: + "</html>"));
52: }
53: }
54: }
55: }
|