//================================================================================================== // G r a p h i c Java // L a y o u t S h e l l // 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 create a shell around a component so it always keeps its preferred size. */
// Package //--------------------------------------------------------------------------------------- package bpp.graphic;
// Importation //----------------------------------------------------------------------------------- import java.awt.*; import java.awt.event.*;
// L a y o u t S h e l l Class //------------------------------------------------------------------ /*CLASS LayoutShell */ /* Represents a shell around a component that allows it not to comply with the size contraints forced by the layout that is receiving the component. */ public class LayoutShell extends Panel { //--------------------------------------------------------------------------------------Constructor /*METHOD LayoutShell */ /* Builds a layout shell around a given component. */ public LayoutShell(Component agComponent) { super(new FlowLayout(FlowLayout.CENTER,0,0)); add(agComponent); } //--------------------------------------------------------------------------------------Constructor /*METHOD LayoutShell */ /* Builds a layout shell with a title around a given component. */ public LayoutShell(Component agComponent,String agTitle) { super(new FlowLayout(FlowLayout.CENTER,0,0));
Panel lcPanel = new Panel(new BorderLayout(0,0)); Label lcLabel = new Label(agTitle,Label.CENTER);
lcPanel.add(lcLabel,BorderLayout.NORTH); lcPanel.add(agComponent,BorderLayout.CENTER); add(lcPanel); } }
// End //------------------------------------------------------------------------------------------- |
|