//mainFrame.java // generates a frame to cover the screen for the text. //Title: General Classes //Version: 0.1 //Author: John Krantz //Company: Hanover College //Description: Some general classes to control the look and feel //of the book package. package util; import java.awt.*; import javax.swing.JFrame; /** * Constructs a screen size frame with the defaults already inplace * base upon JFrame. * @author John Krantz * @version 0.1 */ public class MainFrame extends JFrame { static final long serialVersionUID = 0; public Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); public final static Dimension SCREENSIZE = Toolkit.getDefaultToolkit().getScreenSize(); // parameterless constructor // make a full screensized window with black background and no title // and no icon public MainFrame() { this.setSize(Toolkit.getDefaultToolkit().getScreenSize().width, Toolkit.getDefaultToolkit().getScreenSize().height*29/30); jbInit(); } // add a title to the same frame as above. public MainFrame(String title){ this.setTitle(title); jbInit(); this.setSize(Toolkit.getDefaultToolkit().getScreenSize().width, Toolkit.getDefaultToolkit().getScreenSize().height*29/30); } // no title on the frame but given a specific size public MainFrame(int x, int y){ this.setSize(x,y); jbInit(); } // title and specific size to frame public MainFrame(String title, int x, int y){ this.setSize(x,y); this.setTitle(title); jbInit(); } // not title but the window with be a specific percentage of the // screen size public MainFrame(double pctX, double pctY){ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); this.setSize((int)(screenSize.width*pctX), (int)(screenSize.height*pctY)); jbInit(); } // now the frame will have a title and be a specific // percentage of the screen size public MainFrame(String title, double pctX, double pctY){ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); this.setTitle(title); this.setSize((int)(screenSize.width*pctX), (int)(screenSize.height*pctY)); jbInit(); } // set the background and foreground. private void jbInit() { this.getContentPane().setBackground(Color.black); this.getContentPane().setForeground(Color.white); } public int getFrameHeight(){ return getHeight();} public int getFrameWidth(){ return getWidth();} }