001: /*
002: * HeapMemoryDialog.java
003: *
004: * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
019: *
020: */
021:
022: package org.underworldlabs.swing;
023:
024: import java.awt.Container;
025: import java.awt.Dialog;
026: import java.awt.Frame;
027: import java.awt.Insets;
028: import java.awt.GridBagConstraints;
029: import java.awt.GridBagLayout;
030: import java.awt.event.ActionEvent;
031: import java.awt.event.ActionListener;
032:
033: import javax.swing.JButton;
034: import javax.swing.JDialog;
035:
036: /* ----------------------------------------------------------
037: * CVS NOTE: Changes to the CVS repository prior to the
038: * release of version 3.0.0beta1 has meant a
039: * resetting of CVS revision numbers.
040: * ----------------------------------------------------------
041: */
042:
043: /**
044: *
045: * @author Takis Diakoumis
046: * @version $Revision: 1.4 $
047: * @date $Date: 2006/05/14 06:56:07 $
048: */
049: public class HeapMemoryDialog extends JDialog implements ActionListener {
050:
051: private HeapMemoryPanel heapPanel;
052:
053: public HeapMemoryDialog(Frame owner) {
054: super (owner, "Java Heap Memory", false);
055: try {
056: jbInit();
057: } catch (Exception e) {
058: e.printStackTrace();
059: }
060: }
061:
062: public HeapMemoryDialog(Dialog owner) {
063: super (owner, "Java Heap Memory", false);
064: try {
065: jbInit();
066: } catch (Exception e) {
067: e.printStackTrace();
068: }
069: }
070:
071: private void jbInit() {
072: heapPanel = new HeapMemoryPanel();
073:
074: JButton closeButton = new JButton("Close");
075: closeButton.addActionListener(this );
076:
077: Container c = this .getContentPane();
078: c.setLayout(new GridBagLayout());
079:
080: GridBagConstraints gbc = new GridBagConstraints();
081: gbc.insets = new Insets(2, 2, 0, 1);
082: gbc.anchor = GridBagConstraints.NORTHWEST;
083: gbc.fill = GridBagConstraints.BOTH;
084: c.add(heapPanel, gbc);
085: gbc.gridy = 1;
086: gbc.fill = GridBagConstraints.NONE;
087: gbc.insets.bottom = 10;
088: gbc.anchor = GridBagConstraints.CENTER;
089: c.add(closeButton, gbc);
090:
091: setResizable(false);
092: setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
093:
094: pack();
095: setLocation(GUIUtils
096: .getLocationForDialog(getOwner(), getSize()));
097: setVisible(true);
098: }
099:
100: public void actionPerformed(ActionEvent e) {
101: dispose();
102: }
103:
104: public void dispose() {
105: if (heapPanel != null) {
106: heapPanel.stopTimer();
107: }
108: super.dispose();
109: }
110:
111: }
|