1 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.ConstantUtf8Info; 13 import org.gjt.jclasslib.util.ExtendedJLabel; 14 15 import javax.swing.tree.TreePath ; 16 17 23 public class ConstantUtf8InfoDetailPane extends AbstractConstantInfoDetailPane { 24 25 27 private ExtendedJLabel lblByteLength; 28 private ExtendedJLabel lblByteLengthComment; 29 private ExtendedJLabel lblStringLength; 30 private ExtendedJLabel lblString; 31 32 36 public ConstantUtf8InfoDetailPane(BrowserServices services) { 37 super(services); 38 } 39 40 protected void setupLabels() { 41 42 addDetailPaneEntry(normalLabel("Length of byte array:"), 43 lblByteLength = highlightLabel(), 44 lblByteLengthComment = highlightLabel()); 45 46 addDetailPaneEntry(normalLabel("Length of string:"), 47 lblStringLength = highlightLabel()); 48 49 addDetailPaneEntry(normalLabel("String:"), 50 null, 51 lblString = highlightLabel()); 52 53 } 54 55 public void show(TreePath treePath) { 56 57 int constantPoolIndex = constantPoolIndex(treePath); 58 59 try { 60 ConstantUtf8Info entry = services.getClassFile().getConstantPoolUtf8Entry(constantPoolIndex); 61 lblByteLength.setText(entry.getBytes().length); 62 lblStringLength.setText(entry.getString().length()); 63 lblString.setText(getConstantPoolEntryName(constantPoolIndex)); 64 } catch (InvalidByteCodeException ex) { 65 lblByteLength.setText(-1); 66 lblStringLength.setText(-1); 67 lblByteLengthComment.setText(MESSAGE_INVALID_CONSTANT_POOL_ENTRY); 68 } 69 70 super.show(treePath); 71 } 72 73 } 74 75 | Popular Tags |