cool, thnx man that works but just 1 more thing. the jpanel only get deleted like 10 seconds after i click on the delete button.
if(delete == JOptionPane.YES_OPTION){
this.getParent().remove(this);
this.validate();
}
is there a way to make it get deleted almost instantly after the user clicks on the delete button?
It gets removed as soon as the code is executed unless you have some other code that is blocking the GUI from repainting itself.
If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program[/url] (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
Don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the posted code retains its original formatting.
im using multiple classes so itll be kinda difficult to make a SSCCE. but this is the method that deals with deleting the jpanel:
public void buildExitDialog(){
exit = JOptionPane.showConfirmDialog(mainFrame, "Are you sure you want to exit?", "Exit", JOptionPane.YES_NO_OPTION);
if(exit == JOptionPane.YES_OPTION){
System.exit(0);
}
}
> so itll be kinda difficult to make a SSCCE.
Then is will impossible to offer further help since the information provided give no indication of what your code is like. The code you posted doesn't even show the remove code so I have no idea what you are doing. Why do you even care about removing the panel if you are simply going to exit the GUI.
The GUI won't repaint itself until you answer the question and the modal dialog is closed.
a d amn sorry oke wrong method ^^
public void buildDeleteDialog(){
delete = JOptionPane.showConfirmDialog(this, "Are you sure you want to delete this contact?", "Delete", JOptionPane.YES_NO_OPTION);
if(delete == JOptionPane.YES_OPTION){
getParent().remove(this);
validate();
}
}