I am using Java Swing to create a JDialog, and i am trying to create a Show/Hide details button to show/hide a report at the bottom of this JDialog.
It works fine for me, but i want to do this with time, to add a small animation effect while showing/hiding the report, i have used TimerTask but it's just showing the report directly without any slow motion ... Here's my current code :
private void showHideDetailsButtonActionPerformed() {
final MyDialog myDialog = this;
int fullHeight = this.getHeight();
int smallHeight = this.getHeight()/2 - 4;
this.setSize( this.getWidth(), smallHeight ); // By default hide the report.
if( this.getHeight() == smallHeight ) { // Show details.
new Timer().schedule(
new java.util.TimerTask() {
@Override
public void run() {
while( myDialog.getHeight() < fullHeight ) {
myDialog.setSize( myDialog.getWidth(), myDialog.getHeight() + 1 );
System.out.println( myDialog.getHeight() );
}
}
},
800
);
}
}