package Utilities ; import java.awt.*; import java.applet.* ; import java.awt.event.*; import javax.swing.*; //============================================================================== /** * * Container object with JApplet, JFrame, and JDialog properties.
* */ //============================================================================== public class SuperContainer{ Container InputContainer ; JRootPane RP ; Frame SuperFrame ; // Frame of overall screen. boolean IsJApplet = false ; boolean IsJFrame = false ; boolean IsJDialog = false ; boolean IsWindow = false ; /** * Container object with JApplet, JFrame, and JDialog properties. * * @param InputContainer Container, either a JApplet, JFrame, or JDialog. */ public SuperContainer(Container InputContainer){ this.InputContainer = InputContainer ; if(InputContainer instanceof JApplet){ IsJApplet = true ; RP = ((JApplet) InputContainer).getRootPane() ; } else if(InputContainer instanceof JFrame){ IsJFrame = true ; RP = ((JFrame) InputContainer).getRootPane() ; } else if(InputContainer instanceof JDialog){ RP = ((JDialog) InputContainer).getRootPane() ; IsJDialog = true ; } else{ System.out.println("SuperContainer: Bad input type!") ; } IsWindow = IsJFrame | IsJDialog ; SuperFrame = GetParentFrame.GetParentFrame(RP.getContentPane()) ; } //------------------------------------------------------------------------------ public Container getContentPane(){ return RP.getContentPane() ; } //------------------------------------------------------------------------------ public boolean isApplet(){ return IsJApplet ; } //------------------------------------------------------------------------------ public boolean isWindow(){ return IsWindow ; } //------------------------------------------------------------------------------ public void setResizable(boolean Resizable) { if(IsJDialog){ ((Dialog)InputContainer).setResizable(Resizable) ; } else{ SuperFrame.setResizable(Resizable) ; } } //------------------------------------------------------------------------------ public void setTitle(String Title) { if(IsJFrame){ ((JFrame) InputContainer).setTitle(Title); } else if(IsJDialog){ ((JDialog) InputContainer).setTitle(Title); } return ; } //------------------------------------------------------------------------------ public void addWindowListener(WindowListener WL) { if (IsWindow){ ((Window)InputContainer).addWindowListener(WL) ; } return ; } //------------------------------------------------------------------------------ public void setLocation( Point P ) { if (IsWindow){ ((Window)InputContainer).setLocation(P) ; } return ; } //------------------------------------------------------------------------------ public void setSize( Dimension D ) { if (IsWindow){ ((Window)InputContainer).setSize(D) ; } return ; } //------------------------------------------------------------------------------ public void setVisible(boolean Visible) { ((Component)InputContainer).setVisible(Visible) ; return ; } //------------------------------------------------------------------------------ public void dispose() { if (IsWindow){ ((Window)InputContainer).dispose() ; } else{ // Restart ? } return ; } //------------------------------------------------------------------------------ public Point getLocation() { if (IsWindow){ return ((Window)InputContainer).getLocation() ; } else{ return null ; } } //------------------------------------------------------------------------------ public void pack() { if (IsWindow){ ((Window)InputContainer).pack() ; } return ; } //------------------------------------------------------------------------------ public Dimension getSize() { if (IsWindow){ return ((Window)InputContainer).getSize() ; } else{ return null ; } } //------------------------------------------------------------------------------ public void setIconImage(Image I) { if (IsWindow){ SuperFrame.setIconImage(I) ; } } //------------------------------------------------------------------------------ public Frame superFrame() { return SuperFrame ; } //------------------------------------------------------------------------------ public void showStatus(String Status) { if (!IsWindow){ ((Applet)InputContainer).getAppletContext().showStatus(Status) ; } } //------------------------------------------------------------------------------ public Component getGlassPane() { return RP.getGlassPane() ; } //------------------------------------------------------------------------------ public void setGlassPane(Component GP) { RP.setGlassPane(GP) ; } //------------------------------------------------------------------------------ public JRootPane getRootPane() { return RP.getRootPane() ; } //------------------------------------------------------------------------------ public void addMouseListener(MouseListener ML) { RP.addMouseListener(ML); } //------------------------------------------------------------------------------ } //==============================================================================