KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > helloworld > renderer > HwTableRenderer


1 /*******************************************************************************
2  * Copyright (c) 2004, Dirk von der Weiden.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * Dirk von der Weiden - initial API and implementation
10  *
11  * Created on 26.02.2005
12  *
13  * date: 26.02.2005
14  * project: WiSer-HelloWorld
15  *
16  * *******************************************************************************/

17
18 package helloworld.renderer;
19
20 import java.awt.*;
21
22 import Jmc.commonGui.*;
23 import Jmc.commonGui.loader.*;
24 import Jmc.baseGui.gui_fixedSize;
25 import Jmc.baseTools.*;
26
27 /**
28  * @author Dirk
29  *
30  * date: 21.02.2005
31  *
32  * <p>
33  * Purpose: This example shows how the render mechanism of the WidgetServer framework
34  * works.
35  * </p>
36  */

37 public class HwTableRenderer implements base_tableItemRenderer_if
38 {
39   /**
40      * <p>
41      * Renderes a list item
42      * </p><p>
43      *
44      * @return rendered widget
45      * </p><p>
46      * @param xToRender object wich has to be rendered
47      * @param xRow row
48      * @param xCol collumn
49      * @param xTable table widget
50      * </p>
51      */

52     public base_guiWidget_if pcmf_getRenderWidget(Object JavaDoc xToRender, int xRow, int xCol, base_table_if xTable)
53     {
54         // get all relevant widgets from the registry
55
base_appl_if l_appl = (base_appl_if)base_registredObject.pcmf_getObjByName(base_appl_if.MY_APPL);
56     base_image_if l_img = (base_image_if)base_registredObject.pcmf_getObjByName("root_icon");
57     base_image_if l_img2 = (base_image_if)base_registredObject.pcmf_getObjByName("entry_icon");
58     
59     // create a textfield
60
base_text_if l_text = l_appl.pcmf_getGuiObjFactory().pcmf_createText(l_appl.pcmf_getApplType(), xToRender.toString(), "-" + xToRender.toString(), l_appl);
61
62     // row 0 is the table header
63
if (xRow == 0)
64     {
65       l_text.pcmf_setFont(new base_fontDesc("ARIAL", 12, Font.BOLD));
66       l_text.pcmf_setBorder(2);
67       l_text.pcmf_setFixedSize(130, 20, gui_fixedSize.FIX_SIZE);
68       l_text.pcmf_setIcon(l_img);
69     }
70     else
71     {
72         // separate odd and even rows
73
l_text.pcmf_setFont(new base_fontDesc("ARIAL", 12, Font.ITALIC));
74       l_text.pcmf_setFixedSize(130, 20, gui_fixedSize.FIX_SIZE);
75       l_text.pcmf_setIcon(l_img2);
76       if (xRow % 2 == 0)
77         l_text.pcmf_setBgColor("#FFA000");
78       else
79         l_text.pcmf_setBgColor("#A0A000");
80     }
81     
82     return (l_text);
83     }
84
85 }
86
Popular Tags