home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / java.z / Toolkit.java < prev    next >
Text File  |  1996-05-03  |  7KB  |  237 lines

  1. /*
  2.  * @(#)Toolkit.java    1.52 96/03/27 Sami Shaio
  3.  *
  4.  * Copyright (c) 1995 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19.  
  20. package java.awt;
  21.  
  22. import java.util.Properties;
  23. import java.awt.peer.*;
  24. import java.awt.image.ImageObserver;
  25. import java.awt.image.ImageProducer;
  26. import java.awt.image.ColorModel;
  27. import java.net.URL;
  28.  
  29. /**
  30.  * An AWT toolkit. It is used to bind the abstract AWT classes
  31.  * to a particular native toolkit implementation.
  32.  *
  33.  * @version     1.52, 27 Mar 1996
  34.  * @author    Sami Shaio
  35.  * @author    Arthur van Hoff
  36.  */
  37. public abstract class  Toolkit {
  38.  
  39.     /**
  40.      * Uses the specified Peer interface to create a new Button.
  41.      * @param target the Button to be created
  42.      */
  43.     protected abstract ButtonPeer     createButton(Button target);
  44.  
  45.     /**
  46.      * Uses the specified Peer interface to create a new TextField.      
  47.      * @param target the TextField to be created
  48.      */
  49.     protected abstract TextFieldPeer     createTextField(TextField target);
  50.  
  51.     /**
  52.      * Uses the specified Peer interface to create a new Label.      
  53.      * @param target the Label to be created
  54.      */
  55.     protected abstract LabelPeer     createLabel(Label target);
  56.  
  57.     /**
  58.      * Uses the specified Peer interface to create a new List.      
  59.      * @param target the List to be created
  60.      */
  61.     protected abstract ListPeer     createList(List target);
  62.  
  63.     /**
  64.      * Uses the specified Peer interface to create a new Checkbox.      
  65.      * @param target the Checkbox to be created
  66.      */
  67.     protected abstract CheckboxPeer     createCheckbox(Checkbox target);
  68.  
  69.     /**
  70.      * Uses the specified Peer interface to create a new Scrollbar.      
  71.      * @param target the Scrollbar to be created
  72.      */
  73.     protected abstract ScrollbarPeer     createScrollbar(Scrollbar target);
  74.  
  75.     /**
  76.      * Uses the specified Peer interface to create a new TextArea.      
  77.      * @param target the TextArea to be created
  78.      */
  79.     protected abstract TextAreaPeer      createTextArea(TextArea target);
  80.  
  81.     /**
  82.      * Uses the specified Peer interface to create a new Choice.      
  83.      * @param target the Choice to be created
  84.      */
  85.     protected abstract ChoicePeer    createChoice(Choice target);
  86.  
  87.     /**
  88.      * Uses the specified Peer interface to create a new Frame.
  89.      * @param target the Frame to be created
  90.      */
  91.     protected abstract FramePeer      createFrame(Frame target);
  92.  
  93.     /**
  94.      * Uses the specified Peer interface to create a new Canvas.
  95.      * @param target the Canvas to be created
  96.      */
  97.     protected abstract CanvasPeer     createCanvas(Canvas target);
  98.  
  99.     /**
  100.      * Uses the specified Peer interface to create a new Panel.
  101.      * @param target the Panel to be created
  102.      */
  103.     protected abstract PanelPeer      createPanel(Panel target);
  104.  
  105.     /**
  106.      * Uses the specified Peer interface to create a new Window.
  107.      * @param target the Window to be created
  108.      */
  109.     protected abstract WindowPeer      createWindow(Window target);
  110.  
  111.     /**
  112.      * Uses the specified Peer interface to create a new Dialog.
  113.      * @param target the Dialog to be created
  114.      */
  115.     protected abstract DialogPeer      createDialog(Dialog target);
  116.  
  117.     /**
  118.      * Uses the specified Peer interface to create a new MenuBar.
  119.      * @param target the MenuBar to be created
  120.      */
  121.     protected abstract MenuBarPeer      createMenuBar(MenuBar target);
  122.  
  123.     /**
  124.      * Uses the specified Peer interface to create a new Menu.
  125.      * @param target the Menu to be created
  126.      */
  127.     protected abstract MenuPeer      createMenu(Menu target);
  128.  
  129.     /**
  130.      * Uses the specified Peer interface to create a new MenuItem.
  131.      * @param target the MenuItem to be created
  132.      */
  133.     protected abstract MenuItemPeer      createMenuItem(MenuItem target);
  134.  
  135.     /**
  136.      * Uses the specified Peer interface to create a new FileDialog.
  137.      * @param target the FileDialog to be created
  138.      */
  139.     protected abstract FileDialogPeer    createFileDialog(FileDialog target);
  140.  
  141.     /**
  142.      * Uses the specified Peer interface to create a new CheckboxMenuItem.
  143.      * @param target the CheckboxMenuItem to be created
  144.      */
  145.     protected abstract CheckboxMenuItemPeer    createCheckboxMenuItem(CheckboxMenuItem target);
  146.  
  147.     /**
  148.      * Gets the size of the screen.
  149.      */
  150.     public abstract Dimension getScreenSize();
  151.  
  152.     /**
  153.      * Returns the screen resolution in dots-per-inch.
  154.      */
  155.     public abstract int getScreenResolution();
  156.  
  157.     /**
  158.      * Returns the ColorModel of the screen.
  159.      */
  160.     public abstract ColorModel getColorModel();
  161.  
  162.     /**
  163.      * Returns the names of the available fonts.
  164.      */
  165.     public abstract String[] getFontList();
  166.  
  167.     /**
  168.      * Returns the screen metrics of the font.
  169.      */
  170.     public abstract FontMetrics getFontMetrics(Font font);
  171.  
  172.     /**
  173.      * Syncs the graphics state; useful when doing animation.
  174.      */
  175.     public abstract void sync();
  176.  
  177.     /**
  178.      * The default toolkit.
  179.      */
  180.     private static Toolkit toolkit;
  181.  
  182.     /**
  183.      * Returns the default toolkit. This is controlled by the
  184.      * "awt.toolkit" property.
  185.      * @exception AWTError Toolkit not found or could not be instantiated.
  186.      */
  187.     public static synchronized Toolkit getDefaultToolkit() {
  188.     if (toolkit == null) {
  189.         String nm = System.getProperty("awt.toolkit", "sun.awt.motif.MToolkit");
  190.         try {
  191.         toolkit = (Toolkit)Class.forName(nm).newInstance();
  192.         } catch (ClassNotFoundException e) {
  193.         throw new AWTError("Toolkit not found: " + nm);
  194.         } catch (InstantiationException e) {
  195.         throw new AWTError("Could not instantiate Toolkit: " + nm);
  196.         } catch (IllegalAccessException e) {
  197.         throw new AWTError("Could not access Toolkit: " + nm);
  198.         }
  199.     }
  200.     return toolkit;
  201.     }
  202.  
  203.     /**
  204.      * Returns an image which gets pixel data from the specified file.
  205.      * @param filename the file containing the pixel data in one of
  206.      * the recognized file formats
  207.      */
  208.     public abstract Image getImage(String filename);
  209.  
  210.     /**
  211.      * Returns an image which gets pixel data from the specified URL.
  212.      * @param url the URL to use in fetching the pixel data
  213.      */
  214.     public abstract Image getImage(URL url);
  215.  
  216.     /**
  217.      * Prepares an image for rendering on the default screen at the
  218.      * specified width and height.
  219.      */
  220.     public abstract boolean prepareImage(Image image, int width, int height,
  221.                      ImageObserver observer);
  222.  
  223.     /**
  224.      * Returns the status of the construction of the indicated method
  225.      * at the indicated width and height for the default screen.
  226.      */
  227.     public abstract int checkImage(Image image, int width, int height,
  228.                    ImageObserver observer);
  229.  
  230.     /**
  231.      * Creates an image with the specified image producer.
  232.      * @param producer the image producer to be used
  233.      */
  234.     public abstract Image createImage(ImageProducer producer);
  235.  
  236. }
  237.