KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > common > properties > PrincipalsRenderer


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * PrincipalsRenderer.java
26  *
27  * Created on March 19, 2002, 11:56 AM
28  */

29
30 package com.sun.enterprise.tools.common.properties;
31
32 import javax.swing.*;
33 import java.util.*;
34 import java.text.*;
35
36 /**
37  *
38  * @author shirleyc
39  * @version
40  */

41 public class PrincipalsRenderer extends JLabel implements javax.swing.table.TableCellRenderer JavaDoc {
42     
43     private static java.util.ResourceBundle JavaDoc bundle =
44         java.util.ResourceBundle.getBundle("com.sun.enterprise.tools.common.properties.Bundle"); //NOI18N
45

46     public PrincipalsRenderer() {
47     }
48
49     public java.awt.Component JavaDoc getTableCellRendererComponent(javax.swing.JTable JavaDoc jTable, java.lang.Object JavaDoc value, boolean isSelected, boolean hasFocus, int row, int column) {
50         if (value == null) {
51             setText(MessageFormat.format(bundle.getString("PLURAL_PRIN_CAPTION"), new Object JavaDoc[] {"0"})); //NOI18N
52
}
53         else if (value instanceof Vector) {
54             if (((Vector)value).size() == 1)
55                 setText(bundle.getString("SINGLE_PRIN_CAPTION")); //NOI18N
56
else
57                 setText(MessageFormat.format(bundle.getString("PLURAL_PRIN_CAPTION"), new Object JavaDoc[] {new Integer JavaDoc(((Vector)value).size())})); //NOI18N
58
}
59         else
60             System.out.println(value);
61         return this;
62     }
63 }
64
Popular Tags