if (h != m_TextHeight) { m_TextHeight = h;
if (h != lastHeight) { lastHeight = h;
  public LogPanel() {    m_LogText.setEditable(false);    m_LogText.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));    m_StatusLab.setBorder(BorderFactory.createCompoundBorder(			  BorderFactory.createTitledBorder("Status"),			  BorderFactory.createEmptyBorder(0, 5, 5, 5)));        JPanel p1 = new JPanel();    p1.setBorder(BorderFactory.createTitledBorder("Log"));    p1.setLayout(new BorderLayout());    JScrollPane js = new JScrollPane(m_LogText);    p1.add(js, BorderLayout.CENTER);    m_TextHeight = js.getViewport().getViewSize().height;    js.getViewport().addChangeListener(new ChangeListener() {      public void stateChanged(ChangeEvent e) {	JViewport vp = (JViewport)e.getSource();	int h = vp.getViewSize().height; 	// If new content is added ViewSize changes. This event is also	// fired when the user moves the scrollbar - in this case we	// don't want to move it back to the bottom.	if (h != m_TextHeight) {	  m_TextHeight = h;	  int x = h - vp.getExtentSize().height;	  vp.setViewPosition(new Point(0, x));	}      }    });    setLayout(new BorderLayout());    add(p1, BorderLayout.CENTER);    add(m_StatusLab, BorderLayout.SOUTH);  }