KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > jclasslib > browser > detail > constants > ConstantIntegerInfoDetailPane


1 /*
2     This library is free software; you can redistribute it and/or
3     modify it under the terms of the GNU General Public
4     License as published by the Free Software Foundation; either
5     version 2 of the license, or (at your option) any later version.
6 */

7
8 package org.gjt.jclasslib.browser.detail.constants;
9
10 import org.gjt.jclasslib.browser.BrowserServices;
11 import org.gjt.jclasslib.structures.InvalidByteCodeException;
12 import org.gjt.jclasslib.structures.constants.ConstantIntegerInfo;
13 import org.gjt.jclasslib.util.ExtendedJLabel;
14
15 import javax.swing.tree.TreePath JavaDoc;
16
17 /**
18     Detail pane showing a <tt>CONSTANT_Integer</tt> constant pool entry.
19  
20     @author <a HREF="mailto:jclasslib@ej-technologies.com">Ingo Kegel</a>
21     @version $Revision: 1.5 $ $Date: 2003/08/18 08:16:34 $
22 */

23 public class ConstantIntegerInfoDetailPane extends AbstractConstantInfoDetailPane {
24
25     // Visual components
26

27     private ExtendedJLabel lblBytes;
28     private ExtendedJLabel lblInt;
29     private ExtendedJLabel lblComment;
30     
31     /**
32         Constructor.
33         @param services the associated browser services.
34      */

35     public ConstantIntegerInfoDetailPane(BrowserServices services) {
36         super(services);
37     }
38     
39     protected void setupLabels() {
40         
41         addDetailPaneEntry(normalLabel("Bytes:"),
42                            lblBytes = highlightLabel());
43
44         addDetailPaneEntry(normalLabel("Integer:"),
45                            lblInt = highlightLabel(),
46                            lblComment = highlightLabel());
47
48     }
49
50     public void show(TreePath JavaDoc treePath) {
51         
52         int constantPoolIndex = constantPoolIndex(treePath);
53
54         try {
55             ConstantIntegerInfo entry = (ConstantIntegerInfo)services.getClassFile().getConstantPoolEntry(constantPoolIndex, ConstantIntegerInfo.class);
56             lblBytes.setText(entry.getFormattedBytes());
57             lblInt.setText(entry.getInt());
58         } catch (InvalidByteCodeException ex) {
59             lblComment.setText(MESSAGE_INVALID_CONSTANT_POOL_ENTRY);
60         }
61         
62         super.show(treePath);
63     }
64     
65 }
66
67
Popular Tags