/** Sets the call stack with the given vector of method names. */ public void setContents(Vector newMethodNames) { methodNames = (Vector) newMethodNames.clone(); callStackTable.revalidate(); Rectangle r = callStackTable.getCellRect(newMethodNames.size() - 1, 0, true); callStackTable.scrollRectToVisible(r); repaint(); }
// Initializing this component. private void jbInit() { callStackTable.addFocusListener( new FocusListener() { public void focusGained(FocusEvent e) { callStackTable_focusGained(e); } public void focusLost(FocusEvent e) { callStackTable_focusLost(e); } }); callStackTable.setTableHeader(null); callStackTable.setDefaultRenderer(callStackTable.getColumnClass(0), getCellRenderer()); scrollPane = new JScrollPane(callStackTable); setVisibleRows(DEFAULT_VISIBLE_ROWS); scrollPane.setLocation(0, 27); setBorder(BorderFactory.createEtchedBorder()); // this.setLayout(null); this.setLayout(new GridBagLayout()); nameLbl.setText("Call Stack"); nameLbl.setBounds(new Rectangle(3, 4, 70, 23)); nameLbl.setFont(Utilities.labelsFont); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.ipadx = 0; c.ipady = 0; c.weightx = 1; c.weighty = 1; c.gridwidth = 7; c.gridheight = 1; c.anchor = GridBagConstraints.PAGE_END; c.gridx = 0; c.gridy = 2; this.add(scrollPane, c); c.fill = GridBagConstraints.HORIZONTAL; c.ipadx = 0; c.ipady = 0; c.weightx = 1; c.weighty = 0.0; c.gridwidth = 3; c.gridheight = 1; c.anchor = GridBagConstraints.FIRST_LINE_START; c.gridx = 0; c.gridy = 0; c.insets = new Insets(5, 0, 0, 0); this.add(nameLbl, c); }
/** Sets the number of visible rows. */ public void setVisibleRows(int num) { int tableHeight = num * callStackTable.getRowHeight(); scrollPane.setSize(getTableWidth(), tableHeight + 3); setPreferredSize(new Dimension(getTableWidth(), tableHeight + 30)); setSize(getTableWidth(), tableHeight + 30); }
/** Resets the contents of this CallStackComponent. */ public void reset() { methodNames.removeAllElements(); callStackTable.revalidate(); callStackTable.clearSelection(); }
/** The action of the table loosing focus */ public void callStackTable_focusLost(FocusEvent e) { callStackTable.clearSelection(); }