Skip to content

Commit cc51471

Browse files
authored
Merge pull request #16 from SNException/master
Frame location adjustment
2 parents 36a9632 + 2415051 commit cc51471

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/simplejavatexteditor/About.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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

src/simplejavatexteditor/UI.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)