File tree Expand file tree Collapse file tree 2 files changed +31
-4
lines changed
Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change 1414 * @modifiedby Achintha Gunasekara
1515 * @modweb http://www.achinthagunasekara.com
1616 * @modemail contact@achinthagunasekara.com
17+ *
18+ * @Modifiedby SidaDan
19+ * @modemail Fschultz@sinf.de
20+ * Bug fixed. If JTextArea txt not empty and the user will
21+ * shutdown the Simple Java NotePad, then the Simple Java NotePad
22+ * is only hidden (still running). So I added a WindowListener
23+ * an call method dispose() for this frame.
24+ * Tested with java 8.
1725 */
1826
1927package simplejavatexteditor ;
2028
2129import javax .swing .*;
2230import java .awt .FlowLayout ;
31+ import java .awt .event .WindowAdapter ;
32+ import java .awt .event .WindowEvent ;
2333
2434public class About {
2535
@@ -32,6 +42,15 @@ public About(UI ui) {
3242 panel = new JPanel (new FlowLayout ());
3343 panel .setBorder (BorderFactory .createEmptyBorder (8 , 8 , 8 , 8 ));
3444 frame = new JFrame ();
45+
46+ frame .addWindowListener (new WindowAdapter () {
47+ @ Override
48+ public void windowClosing (WindowEvent e ) {
49+ frame .dispose ();
50+ }
51+ });
52+
53+
3554 frame .setVisible (true );
3655 frame .setSize (500 ,300 );
3756 frame .setLocationRelativeTo (ui );
Original file line number Diff line number Diff line change 1414 * @modifiedby Achintha Gunasekara
1515 * @modweb http://www.achinthagunasekara.com
1616 * @modemail contact@achinthagunasekara.com
17+ *
18+ * @Modifiedby SidaDan
19+ * @modemail Fschultz@sinf.de
20+ * Center this JFrame to the JTextArea
21+ * Bug fixed. If JTextArea txt not empty and the user will
22+ * shutdown the Simple Java NotePad, then the Simple Java NotePad
23+ * is only hidden (still running). We need DISPOSE_ON_CLOSE for
24+ * this JFrame.
25+ * Tested with java 8.
1726 */
1827
1928package simplejavatexteditor ;
@@ -94,11 +103,10 @@ public Find(JTextArea text) {
94103 // Set size window
95104 setSize (width ,height );
96105
97- // Set window position
98- Point center = GraphicsEnvironment .getLocalGraphicsEnvironment ().getCenterPoint ();
99- setLocation (center .x -width /2 , center .y -height /2 );
106+ // center the frame on the frame
107+ setLocationRelativeTo (txt );
100108 setVisible (true );
101- setDefaultCloseOperation (JFrame .HIDE_ON_CLOSE );
109+ setDefaultCloseOperation (JFrame .DISPOSE_ON_CLOSE );
102110 }
103111
104112 public void find () {
You can’t perform that action at this time.
0 commit comments