File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,12 +28,13 @@ public class About {
2828 private String contentText ;
2929 private final JLabel text ;
3030
31- public About () {
31+ public About (UI ui ) {
3232 panel = new JPanel (new FlowLayout ());
3333 panel .setBorder (BorderFactory .createEmptyBorder (8 , 8 , 8 , 8 ));
3434 frame = new JFrame ();
3535 frame .setVisible (true );
3636 frame .setSize (500 ,300 );
37+ frame .setLocationRelativeTo (ui );
3738 text = new JLabel ();
3839 }
3940
Original file line number Diff line number Diff line change @@ -86,6 +86,9 @@ public UI()
8686 // Set the default close operation (exit when it gets closed)
8787 setDefaultCloseOperation (EXIT_ON_CLOSE );
8888
89+ // center the frame on the monitor
90+ setLocationRelativeTo (null );
91+
8992 // Set a default font for the TextArea
9093 textArea = new JTextArea ("" , 0 ,0 );
9194 textArea .setFont (new Font ("Century Gothic" , Font .BOLD , 12 ));
@@ -480,11 +483,11 @@ else if (e.getSource() == saveFile || e.getSource() == saveButton) {
480483
481484 // About Me
482485 else if (e .getSource () == aboutMe || e .getSource () == aboutMeButton ) {
483- new About ().me ();
486+ new About (this ).me ();
484487 }
485488 // About Software
486489 else if (e .getSource () == aboutSoftware || e .getSource () == aboutButton ) {
487- new About ().software ();
490+ new About (this ).software ();
488491 }
489492
490493 }
You can’t perform that action at this time.
0 commit comments