Here:
private void openAnexo() {
new Thread () {
@Override
public void run() {
for (int i = pnl.getWidth(); i <= 200; i++) {
pnl.setPreferredSize(new Dimension(i, 300));
pack();
}
}
}.start();
}
Swing components must be created/updated in the Event Dispatch Thread. Having said this your thread is blocking the EDT causing the GUI becomes unresponsive. You should synchronize this new thread with the EDT by using SwingUtilities.invokeLater(). Or even better you can do repetitive tasks using a Swing Timer which is a convenience class to handle all this concurrency stuff.
For example:
private void openAnexo() {
javax.swing.Timer timer = new javax.swing.Timer(200, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int width = pnl.getWidth();
if(width > 200) {
((javax.swing.Timer)e.getSource()).stop();
} else {
pnl.setPreferredSize(new Dimension(width + 1, 300));
Calculadora.this.pack();
}
}
});
timer.setRepeats(true);
timer.setDelay(200);
timer.start();
}
Take a look to How to Use Swing Timers tutorial for a better explanation.
I don't know what are you trying to achieve with this, but be aware of this: Should I avoid the use of set(Preferred|Maximum|Minimum)Size methods in Java Swing? (Yes we should).