Skip to content

Commit 6261624

Browse files
committed
fixed a bug with double windows
1 parent 168ac27 commit 6261624

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

Main.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import javax.swing.*;
33
import java.awt.event.*;
44

5-
public class Main extends JFrame {
5+
public class Main extends JFrame {
66
// Menubar
77
static JMenuBar menuBar;
88

@@ -48,7 +48,7 @@ public class Main extends JFrame {
4848

4949
setTitle("Eightsoft");
5050
setSize(800, 800);
51-
// setLocation(200, 100);
51+
setLocation(300, 5);
5252
setVisible(true);
5353
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
5454
}
@@ -64,6 +64,7 @@ public void actionPerformed(ActionEvent e) {
6464
else if (e.getSource() == menuItem2) {
6565
// Creating Object
6666
Sorting sort = new Sorting();
67+
setVisible(false); // will close the previous window
6768
System.out.println("Menu Item 2 choosed");
6869
}
6970
else if (e.getSource() == menuItem2) {

Sorting.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,9 @@ public class Sorting extends Main {
5454
pPanel1.setBackground(Color.CYAN);
5555
pPanel2.setBackground(Color.YELLOW);
5656

57-
// pPanel1.add(p1Sorting);
58-
// pPanel2.add(p2Sorting);
59-
// p1Sorting.setVisible(true);
60-
// p2Sorting.setVisible(true);
61-
6257
// Add Panels to the panel
6358
add(pPanel1, BorderLayout.NORTH);
6459
add(pPanel2, BorderLayout.CENTER);
6560

6661
}
67-
6862
}

0 commit comments

Comments
 (0)