Don't call setText() on the popup text component until it is shown

Performance improvement, impacts profiles.
This commit is contained in:
draxdyn 2016-06-01 16:44:35 +02:00
parent 9513b5bf74
commit 415c8cce7e
2 changed files with 14 additions and 1 deletions

View file

@ -155,6 +155,7 @@ public class MageActionCallback implements ActionCallback {
}
data.locationOnScreen = data.component.getLocationOnScreen();
}
data.popupText.updateText();
tooltipPopup = factory.getPopup(data.component, data.popupText, (int) data.locationOnScreen.getX() + data.popupOffsetX, (int) data.locationOnScreen.getY() + data.popupOffsetY + 40);
tooltipPopup.show();
// hack to get popup to resize to fit text

View file

@ -39,6 +39,8 @@ package mage.cards;
* @author BetaSteward_at_googlemail.com
*/
public class TextPopup extends javax.swing.JPanel {
private String text;
private boolean needsUpdate;
/** Creates new form TextPopup */
public TextPopup() {
@ -46,7 +48,17 @@ public class TextPopup extends javax.swing.JPanel {
}
public void setText(String text) {
popupText.setText(text);
if(!text.equals(this.text)) {
this.text = text;
this.needsUpdate = true;
}
}
public void updateText() {
if(this.needsUpdate) {
popupText.setText(this.text);
this.needsUpdate = false;
}
}
/** This method is called from within the constructor to