//================================================================================================== // G r a p h i c Java // F r a m e // By Bruno Bachelet //================================================================================================== // Copyright (c) 1999-2016 // Bruno Bachelet - bruno@nawouak.net - http://www.nawouak.net // // This file is part of the B++ Library. This library is free software; you can redistribute it // and/or modify it under the terms of the GNU Library General Public License as published by the // Free Software Foundation; either version 2 of the License, or (at your option) any later // version. // // This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See // the GNU Library General Public License for more details (http://www.gnu.org).
/*DESCRIPTION*/ /* This module provides a class to represent a frame. */
// Package //--------------------------------------------------------------------------------------- package bpp.graphic;
// F r a m e Class //------------------------------------------------------------------------------ /*CLASS Frame */ /* Represents a frame. */ public class Frame extends java.awt.Frame implements java.awt.event.WindowListener { //---------------------------------------------------------------------------------------Attributes protected boolean atMaster; // Indicates if the frame is the master of the application. //--------------------------------------------------------------------------------------Constructor /*METHOD Frame */ /* Builds a frame. It is possible to indicate if the frame is the master of the application (i.e. the closing of the frame implies the closing of the application) or if it can be resized. */ public Frame(boolean agMaster,boolean agResizable) { super(); addWindowListener(this); setResizable(agResizable); atMaster=agMaster; } //--------------------------------------------------------------------------------------Constructor /*METHOD Frame */ /* Builds a frame with a given title. It is possible to indicate if the frame is the master of the application (i.e. the closing of the frame implies the closing of the application) or if it can be resized. */ public Frame(String agTitle,boolean agMaster,boolean agResizable) { super(agTitle); addWindowListener(this); setResizable(agResizable); atMaster=agMaster; } //-----------------------------------------------------------------------------------------IsMaster /*METHOD Frame */ /* Indicates if the frame is the master of the application. */ public boolean isMaster() { return (atMaster); } //----------------------------------------------------------------------------------------SetMaster /*METHOD Frame */ /* Sets if the frame is the master of the application. */ public void setMaster(boolean agMaster) { atMaster=agMaster; } //-------------------------------------------------------------------------------------------Center /*METHOD Frame */ /* Centers the frame on the screen. */ public void center() { java.awt.Dimension lcFrameSize = getSize(); java.awt.Dimension lcScreenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setLocation((int)(lcScreenSize.getWidth()-lcFrameSize.getWidth())/2, (int)(lcScreenSize.getHeight()-lcFrameSize.getHeight())/2); } //-------------------------------------------------------------------------------------WindowOpened /*METHOD Frame */ /* Called when the window is opened. */ public void windowOpened(java.awt.event.WindowEvent agEvent) {} //-------------------------------------------------------------------------------------WindowClosed /*METHOD Frame */ /* Called when the window is closed. */ public void windowClosed(java.awt.event.WindowEvent agEvent) {} //----------------------------------------------------------------------------------WindowIconified /*METHOD Frame */ /* Called when the window is iconified. */ public void windowIconified(java.awt.event.WindowEvent agEvent) {} //--------------------------------------------------------------------------------WindowDeiconified /*METHOD Frame */ /* Called when the window is deiconified. */ public void windowDeiconified(java.awt.event.WindowEvent agEvent) {} //----------------------------------------------------------------------------------WindowActivated /*METHOD Frame */ /* Called when the window is activated. */ public void windowActivated(java.awt.event.WindowEvent agEvent) {} //--------------------------------------------------------------------------------WindowDeactivated /*METHOD Frame */ /* Called when the window is deactivated. */ public void windowDeactivated(java.awt.event.WindowEvent agEvent) {} //------------------------------------------------------------------------------------WindowClosing /*METHOD Frame */ /* Called when the window is closing. */ public void windowClosing(java.awt.event.WindowEvent agEvent) { dispose(); if (atMaster) System.exit(0); } }
// End //------------------------------------------------------------------------------------------- |
|