/** @author Scott Marshall @author University of Glasgow, MSc IT Project 2001 @author Building an OnLine Course in Computing Fundamentals */ package ukacgla_ATT; import javax.swing.*; import java.awt.event.*; import java.awt.*; /** frameMaker is called by the initiating class for the exercise. Set the size and specs for the DeskTop pane. Call makeGUI() , makeGUI is abstract, as it must instantiate a concrete implementation of the TableUI class. Control then passes to the concrete implementation of TableUI. Provides methods for other classes to create internal frames. */ abstract public class frameMaker extends JApplet{ /** Holds all JInternalFrames generated by program */ protected JDesktopPane desktop; static final int internalFrameWidth = 775; static final int internalFrameHeight = 420; /** * Set to Windows look and feel * 1.Set up frame * 2.Set up JDesktop * 3.Add internal frames to JDesktop. */ public frameMaker(JApplet applet){ //set to Windows look and feel try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception e) { } //contents of frame Container contentPane = applet.getContentPane(); desktop = new JDesktopPane(); desktop.setBackground(Color.lightGray); contentPane.add(desktop); makeGUI(); } /** makeGUI() must instantiate an extended concrete TableUI class through this method */ abstract public void makeGUI(); /** Adds specified JInternalFrame to the existing JDeskTopPane */ public void addFrame(JInternalFrame f){ desktop.add(f); f.setVisible(true); desktop.revalidate(); } /** Returns blank JInternalFrame, with independent window closer */ public JInternalFrame mkFrame(String name,boolean resize, boolean close, int xPos, int yPos, int width, int height){ JInternalFrame tempFrame = new JInternalFrame(name, resize, close); tempFrame.setOpaque(true); tempFrame.setLocation(xPos,yPos); tempFrame.setSize(width, height); tempFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); tempFrame.setVisible(true); tempFrame.setBackground(Color.lightGray); //ensure frame can be selected try { tempFrame.setSelected(true); } catch(java.beans.PropertyVetoException ex) { System.out.println("Exception while selecting internal frame"); } return tempFrame; }//ends mkFrame /** Returns default JInternalFrame width */ public int getInternalFrameWidth(){ return internalFrameWidth; } /** Returns default JInternalFrame height */ public int getInternalFrameHeight() { return internalFrameHeight; } /** Closes and disposes of specified JInternalFrame */ public void closeFrame(JInternalFrame f){ if (f!= null) { f.dispose(); f = null; } } }//ends class