Source code: org/hartmath/HartMathFrame.java
1 /*
2 * HartMathFrame.java
3 * Copyright (C) 2001 Klaus Hartlage
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 package org.hartmath;
21
22 import javax.swing.border.*;
23 import javax.swing.*;
24 import java.awt.event.*;
25 import java.awt.*;
26
27
28 public class HartMathFrame extends JFrame
29 {
30 public HartMathFrame(String[] args)
31 {
32 super("HartMath CAS");
33
34 // setJMenuBar(new MTACMenuBar());
35
36 setContentPane(panel = new HartMathPanel(args, this, false));
37 setJMenuBar(menuBar = new MenuBar(this, panel));
38 panel.setBorder(new EmptyBorder(12,12,12,12));
39
40 setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
41
42 addWindowListener(new WindowHandler());
43
44 pack();
45
46 Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
47 setLocation(d.width / 8, d.height/10);
48
49 setSize(d.width * 3 / 4, d.height * 8 / 10);
50 show();
51
52 frameCount++;
53 }
54
55 // private members
56 private HartMathPanel panel;
57 private MenuBar menuBar;
58 //private static Namespace strings = (Namespace)Namespace.global.get(
59 //"mtac_frame");
60 private static int frameCount;
61
62 class WindowHandler extends WindowAdapter
63 {
64 public void windowActivated(WindowEvent evt)
65 {
66 // panel.getInputField().requestFocus();
67 }
68
69 public void windowClosing(WindowEvent evt)
70 {
71 if(--frameCount == 0) {
72 dispose();
73 System.exit(0);
74 }
75 }
76 }
77 }