Saturday, 19 August 2017

java - How to close a JFrame while opening another JFrame?

I have a frame (main). There are two buttons: Items and Sale.



When I click button Items it opens a frame (Items)
and I want to, when I click on button Sale, it should close the Items and open Sale.



This is Items frame:



public class Items extends JFrame {

public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Items frame = new Items();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}


UPDATE :- here is my sale class



public class Sale extends JFrame {
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Sale frame = new Sale();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...