I have a class called NewSale
which extends JFrame
The JFrame
is used by the user to create a sale (add products, choose payment method, etc).
When the user starts a new sale the software instantiates the NewSale
class.
But when a NewSale
is already instantiated the software disposes the older one and starts a new one.
Like this:
// declaration
public static NewSale newSale;
// the menu item calls this method
public static void startNewSale(){
try{
newSale.dispose();
}catch(Exception e{
}
newSale = newSale();
}
My question is: Is this a good practice or is there a better way to do it?
No comments:
Post a Comment