def show(self): # when the popup becomes visible, get the cursor # so we know how to replace the selection self.dotPosition = self.textComponent.getCaretPosition() self.setSize(self.getPreferredSize()) JWindow.show(self)