//================================================================================================== // G r a p h i c Java // P i c t u r e 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 open frames with a picture in it. */
// Package //--------------------------------------------------------------------------------------- package bpp.graphic;
// Importation //----------------------------------------------------------------------------------- import java.awt.*;
// P i c t u r e F r a m e Class //---------------------------------------------------------------- /*CLASS PictureFrame */ /* Represents a frame with a picture in it. */ public class PictureFrame extends bpp.graphic.Frame { //---------------------------------------------------------------------------------------Attributes protected ImageComponent atPicture; // The component containing the picture. //--------------------------------------------------------------------------------------Constructor /*METHOD PictureFrame */ /* Builds a frame with given title and file containing the picture. It is also possible to indicate if the frame is the master of the application. */ public PictureFrame(String agTitle,String agFileName,boolean agMaster) throws Exception { super(agTitle,agMaster,false);
Panel lcPanel = new Panel(null);
setLayout(new BorderLayout()); add(lcPanel,BorderLayout.CENTER); atPicture=new ImageComponent(agFileName); atPicture.setLocation(0,0); atPicture.setVisible(true); lcPanel.add(atPicture); lcPanel.setSize(atPicture.getSize());
pack(); center(); setVisible(true); pack(); } //---------------------------------------------------------------------------------------------Main /*METHOD PictureFrame */ /* Opens a frame displaying the picture read from a given file. */ public static void main(String agParameterS[]) { if (agParameterS.length==1) { try { new PictureFrame("Picture: "+agParameterS[0],agParameterS[0],true); } catch (Exception agException) { System.out.println("[!] "+agException.getMessage()); } } } }
// End //------------------------------------------------------------------------------------------- |
|