KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > gui > util > TextAreaCellRenderer


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/gui/util/TextAreaCellRenderer.java,v 1.3 2004/02/14 03:34:29 sebb Exp $
2
/*
3  * Copyright 2001-2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17 */

18
19 package org.apache.jmeter.gui.util;
20
21 import java.awt.Component JavaDoc;
22
23 import javax.swing.JTable JavaDoc;
24 import javax.swing.JTextArea JavaDoc;
25 import javax.swing.table.TableCellRenderer JavaDoc;
26
27 /**
28  * @author mstover
29  * @version $Revision: 1.3 $
30  */

31 public class TextAreaCellRenderer implements TableCellRenderer JavaDoc
32 {
33
34     private JTextArea JavaDoc rend = new JTextArea JavaDoc("");
35
36     public Component JavaDoc getTableCellRendererComponent(
37         JTable JavaDoc arg0,
38         Object JavaDoc arg1,
39         boolean arg2,
40         boolean arg3,
41         int arg4,
42         int arg5)
43     {
44         rend = new JTextArea JavaDoc(arg1.toString());
45         rend.revalidate();
46         if (!arg3 && !arg2)
47         {
48             rend.setBackground(JMeterColor.LAVENDER);
49         }
50         if (arg0.getRowHeight(arg4) < getPreferredHeight())
51         {
52             arg0.setRowHeight(arg4, getPreferredHeight());
53         }
54         return rend;
55     }
56
57     public int getPreferredHeight()
58     {
59         return rend.getPreferredSize().height + 5;
60     }
61 }
62
Popular Tags