home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / Toolkit.java < prev    next >
Text File  |  1997-10-01  |  30KB  |  811 lines

  1. /*
  2.  * @(#)Toolkit.java    1.72 97/06/23
  3.  * 
  4.  * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.1_beta
  20.  * 
  21.  */
  22.  
  23. package java.awt;
  24.  
  25. import java.util.Properties;
  26. import java.awt.peer.*;
  27. import java.awt.image.ImageObserver;
  28. import java.awt.image.ImageProducer;
  29. import java.awt.image.ColorModel;
  30. import java.awt.datatransfer.Clipboard;
  31. import java.net.URL;
  32. import java.io.BufferedInputStream;
  33. import java.io.File;
  34. import java.io.FileInputStream;
  35.  
  36. /**
  37.  * This class is the abstract superclass of all actual
  38.  * implementations of the Abstract Window Toolkit. Subclasses of 
  39.  * <code>Toolkit</code> are used to bind the various components 
  40.  * to particular native toolkit implementations.
  41.  * <p>
  42.  * Most applications should not call any of the methods in this
  43.  * class directly. The methods defined by <code>Toolkit</code> are 
  44.  * the "glue" that joins the platform-independent classes in the 
  45.  * <code>java.awt</code> package with their counterparts in 
  46.  * <code>java.awt.peer</code>. Some methods defined by 
  47.  * <code>Toolkit</code> query the native operating system directly.
  48.  *
  49.  * @version     1.72, 06/23/97
  50.  * @author    Sami Shaio
  51.  * @author    Arthur van Hoff
  52.  * @since       JDK1.0
  53.  */
  54. public abstract class  Toolkit {
  55.  
  56.     /**
  57.      * Creates this toolkit's implementation of <code>Button</code> using 
  58.      * the specified peer interface.
  59.      * @param     target the button to be implemented.
  60.      * @return    this toolkit's implementation of <code>Button</code>.
  61.      * @see       java.awt.Button
  62.      * @see       java.awt.peer.ButtonPeer
  63.      * @since     JDK1.0
  64.      */
  65.     protected abstract ButtonPeer     createButton(Button target);
  66.  
  67.     /**
  68.      * Creates this toolkit's implementation of <code>TextField</code> using 
  69.      * the specified peer interface.
  70.      * @param     target the text field to be implemented.
  71.      * @return    this toolkit's implementation of <code>TextField</code>.
  72.      * @see       java.awt.TextField
  73.      * @see       java.awt.peer.TextFieldPeer
  74.      * @since     JDK1.0
  75.      */
  76.     protected abstract TextFieldPeer     createTextField(TextField target);
  77.  
  78.     /**
  79.      * Creates this toolkit's implementation of <code>Label</code> using 
  80.      * the specified peer interface.
  81.      * @param     target the label to be implemented.
  82.      * @return    this toolkit's implementation of <code>Label</code>.
  83.      * @see       java.awt.Label
  84.      * @see       java.awt.peer.LabelPeer
  85.      * @since     JDK1.0
  86.      */
  87.     protected abstract LabelPeer     createLabel(Label target);
  88.  
  89.     /**
  90.      * Creates this toolkit's implementation of <code>List</code> using 
  91.      * the specified peer interface.
  92.      * @param     target the list to be implemented.
  93.      * @return    this toolkit's implementation of <code>List</code>.
  94.      * @see       java.awt.List
  95.      * @see       java.awt.peer.ListPeer
  96.      * @since     JDK1.0
  97.      */
  98.     protected abstract ListPeer     createList(List target);
  99.  
  100.     /**
  101.      * Creates this toolkit's implementation of <code>Checkbox</code> using 
  102.      * the specified peer interface.
  103.      * @param     target the check box to be implemented.
  104.      * @return    this toolkit's implementation of <code>Checkbox</code>.
  105.      * @see       java.awt.Checkbox
  106.      * @see       java.awt.peer.CheckboxPeer
  107.      * @since     JDK1.0
  108.      */
  109.     protected abstract CheckboxPeer     createCheckbox(Checkbox target);
  110.  
  111.     /**
  112.      * Creates this toolkit's implementation of <code>Scrollbar</code> using 
  113.      * the specified peer interface.
  114.      * @param     target the scroll bar to be implemented.
  115.      * @return    this toolkit's implementation of <code>Scrollbar</code>.
  116.      * @see       java.awt.Scrollbar
  117.      * @see       java.awt.peer.ScrollbarPeer
  118.      * @since     JDK1.0
  119.      */
  120.     protected abstract ScrollbarPeer     createScrollbar(Scrollbar target);
  121.  
  122.     /**
  123.      * Creates this toolkit's implementation of <code>ScrollPane</code> using 
  124.      * the specified peer interface.
  125.      * @param     target the scroll pane to be implemented.
  126.      * @return    this toolkit's implementation of <code>ScrollPane</code>.
  127.      * @see       java.awt.ScrollPane
  128.      * @see       java.awt.peer.ScrollPanePeer
  129.      * @since     JDK1.1
  130.      */
  131.     protected abstract ScrollPanePeer     createScrollPane(ScrollPane target);
  132.  
  133.     /**
  134.      * Creates this toolkit's implementation of <code>TextArea</code> using 
  135.      * the specified peer interface.
  136.      * @param     target the text area to be implemented.
  137.      * @return    this toolkit's implementation of <code>TextArea</code>.
  138.      * @see       java.awt.TextArea
  139.      * @see       java.awt.peer.TextAreaPeer
  140.      * @since     JDK1.0
  141.      */
  142.     protected abstract TextAreaPeer      createTextArea(TextArea target);
  143.  
  144.     /**
  145.      * Creates this toolkit's implementation of <code>Choice</code> using 
  146.      * the specified peer interface.
  147.      * @param     target the choice to be implemented.
  148.      * @return    this toolkit's implementation of <code>Choice</code>.
  149.      * @see       java.awt.Choice
  150.      * @see       java.awt.peer.ChoicePeer
  151.      * @since     JDK1.0
  152.      */
  153.     protected abstract ChoicePeer    createChoice(Choice target);
  154.  
  155.     /**
  156.      * Creates this toolkit's implementation of <code>Frame</code> using 
  157.      * the specified peer interface.
  158.      * @param     target the frame to be implemented.
  159.      * @return    this toolkit's implementation of <code>Frame</code>.
  160.      * @see       java.awt.Frame
  161.      * @see       java.awt.peer.FramePeer
  162.      * @since     JDK1.0
  163.      */
  164.     protected abstract FramePeer      createFrame(Frame target);
  165.  
  166.     /**
  167.      * Creates this toolkit's implementation of <code>Canvas</code> using 
  168.      * the specified peer interface.
  169.      * @param     target the canvas to be implemented.
  170.      * @return    this toolkit's implementation of <code>Canvas</code>.
  171.      * @see       java.awt.Canvas
  172.      * @see       java.awt.peer.CanvasPeer
  173.      * @since     JDK1.0
  174.      */
  175.     protected abstract CanvasPeer     createCanvas(Canvas target);
  176.  
  177.     /**
  178.      * Creates this toolkit's implementation of <code>Panel</code> using 
  179.      * the specified peer interface.
  180.      * @param     target the panel to be implemented.
  181.      * @return    this toolkit's implementation of <code>Panel</code>.
  182.      * @see       java.awt.Panel
  183.      * @see       java.awt.peer.PanelPeer
  184.      * @since     JDK1.0
  185.      */
  186.     protected abstract PanelPeer      createPanel(Panel target);
  187.  
  188.     /**
  189.      * Creates this toolkit's implementation of <code>Window</code> using 
  190.      * the specified peer interface.
  191.      * @param     target the window to be implemented.
  192.      * @return    this toolkit's implementation of <code>Window</code>.
  193.      * @see       java.awt.Window
  194.      * @see       java.awt.peer.WindowPeer
  195.      * @since     JDK1.0
  196.      */
  197.     protected abstract WindowPeer      createWindow(Window target);
  198.  
  199.     /**
  200.      * Creates this toolkit's implementation of <code>Dialog</code> using 
  201.      * the specified peer interface.
  202.      * @param     target the dialog to be implemented.
  203.      * @return    this toolkit's implementation of <code>Dialog</code>.
  204.      * @see       java.awt.Dialog
  205.      * @see       java.awt.peer.DialogPeer
  206.      * @since     JDK1.0
  207.      */
  208.     protected abstract DialogPeer      createDialog(Dialog target);
  209.  
  210.     /**
  211.      * Creates this toolkit's implementation of <code>MenuBar</code> using 
  212.      * the specified peer interface.
  213.      * @param     target the menu bar to be implemented.
  214.      * @return    this toolkit's implementation of <code>MenuBar</code>.
  215.      * @see       java.awt.MenuBar
  216.      * @see       java.awt.peer.MenuBarPeer
  217.      * @since     JDK1.0
  218.      */
  219.     protected abstract MenuBarPeer      createMenuBar(MenuBar target);
  220.  
  221.     /**
  222.      * Creates this toolkit's implementation of <code>Menu</code> using 
  223.      * the specified peer interface.
  224.      * @param     target the menu to be implemented.
  225.      * @return    this toolkit's implementation of <code>Menu</code>.
  226.      * @see       java.awt.Menu
  227.      * @see       java.awt.peer.MenuPeer
  228.      * @since     JDK1.0
  229.      */
  230.     protected abstract MenuPeer      createMenu(Menu target);
  231.  
  232.     /**
  233.      * Creates this toolkit's implementation of <code>PopupMenu</code> using 
  234.      * the specified peer interface.
  235.      * @param     target the popup menu to be implemented.
  236.      * @return    this toolkit's implementation of <code>PopupMenu</code>.
  237.      * @see       java.awt.PopupMenu
  238.      * @see       java.awt.peer.PopupMenuPeer
  239.      * @since     JDK1.1
  240.      */
  241.     protected abstract PopupMenuPeer    createPopupMenu(PopupMenu target);
  242.  
  243.     /**
  244.      * Creates this toolkit's implementation of <code>MenuItem</code> using 
  245.      * the specified peer interface.
  246.      * @param     target the menu item to be implemented.
  247.      * @return    this toolkit's implementation of <code>MenuItem</code>.
  248.      * @see       java.awt.MenuItem
  249.      * @see       java.awt.peer.MenuItemPeer
  250.      * @since     JDK1.0
  251.      */
  252.     protected abstract MenuItemPeer      createMenuItem(MenuItem target);
  253.  
  254.     /**
  255.      * Creates this toolkit's implementation of <code>FileDialog</code> using 
  256.      * the specified peer interface.
  257.      * @param     target the file dialog to be implemented.
  258.      * @return    this toolkit's implementation of <code>FileDialog</code>.
  259.      * @see       java.awt.FileDialog
  260.      * @see       java.awt.peer.FileDialogPeer
  261.      * @since     JDK1.0
  262.      */
  263.     protected abstract FileDialogPeer    createFileDialog(FileDialog target);
  264.  
  265.     /**
  266.      * Creates this toolkit's implementation of <code>CheckboxMenuItem</code> using 
  267.      * the specified peer interface.
  268.      * @param     target the checkbox menu item to be implemented.
  269.      * @return    this toolkit's implementation of <code>CheckboxMenuItem</code>.
  270.      * @see       java.awt.CheckboxMenuItem
  271.      * @see       java.awt.peer.CheckboxMenuItemPeer
  272.      * @since     JDK1.0
  273.      */
  274.     protected abstract CheckboxMenuItemPeer    createCheckboxMenuItem(CheckboxMenuItem target);
  275.  
  276.     /**
  277.      * Creates a peer for a component or container.  This peer is windowless
  278.      * and allows the Component and Container classes to be extended directly
  279.      * to create windowless components that are defined entirely in java.
  280.      *
  281.      * @param target The Component to be created.
  282.      */
  283.     protected java.awt.peer.LightweightPeer createComponent(Component target) {
  284.     return new java.awt.LightweightPeer(target);
  285.     }
  286.  
  287.     /**
  288.      * Creates this toolkit's implementation of <code>Font</code> using 
  289.      * the specified peer interface.
  290.      * @param     target the font to be implemented.
  291.      * @return    this toolkit's implementation of <code>Font</code>.
  292.      * @see       java.awt.Font
  293.      * @see       java.awt.peer.FontPeer
  294.      * @since     JDK1.0
  295.      */
  296.     protected abstract FontPeer getFontPeer(String name, int style);
  297.  
  298.     /**
  299.      * Fills in the integer array that is supplied as an argument 
  300.      * with the current system color values.
  301.      * <p>
  302.      * This method is called by the method <code>updateSystemColors</code>
  303.      * in the <code>SystemColor</code> class.
  304.      * @param     an integer array.
  305.      * @see       java.awt.SystemColor#updateSystemColors
  306.      * @since     JDK1.1
  307.      */
  308.     protected void loadSystemColors(int[] systemColors) {
  309.     }
  310.  
  311.     /**
  312.      * Gets the size of the screen.
  313.      * @return    the size of this toolkit's screen, in pixels.
  314.      * @since     JDK1.0
  315.      */
  316.     public abstract Dimension getScreenSize();
  317.  
  318.     /**
  319.      * Returns the screen resolution in dots-per-inch.
  320.      * @return    this toolkit's screen resolution, in dots-per-inch.
  321.      * @since     JDK1.0
  322.      */
  323.     public abstract int getScreenResolution();
  324.  
  325.     /**
  326.      * Determines the color model of this toolkit's screen. 
  327.      * <p>
  328.      * <code>ColorModel</code> is an abstract class that 
  329.      * encapsulates the ability to translate between the 
  330.      * pixel values of an image and its red, green, blue, 
  331.      * and alpha components. 
  332.      * <p>
  333.      * This toolkit method is called by the 
  334.      * <code>getColorModel</code> method 
  335.      * of the <code>Component</code> class. 
  336.      * @return    the color model of this toolkit's screen.
  337.      * @see       java.awt.image.ColorModel
  338.      * @see       java.awt.Component#getColorModel
  339.      * @since     JDK1.0
  340.      */
  341.     public abstract ColorModel getColorModel();
  342.  
  343.     /**
  344.      * Returns the names of the available fonts in this toolkit.<p>
  345.      * For 1.1, the following font names are deprecated (the replacement
  346.      * name follows):
  347.      * <ul>
  348.      * <li>TimesRoman (use Serif)
  349.      * <li>Helvetica (use SansSerif)
  350.      * <li>Courier (use Monospaced)
  351.      * </ul><p>
  352.      * The ZapfDingbats font is also deprecated in 1.1, but only as a
  353.      * separate fontname.  Unicode defines the ZapfDingbat characters
  354.      * starting at \u2700, and as of 1.1 Java supports those characters.
  355.      * @return    the names of the available fonts in this toolkit.
  356.      * @since     JDK1.0
  357.      */
  358.     public abstract String[] getFontList();
  359.  
  360.     /**
  361.      * Gets the screen metrics of the font.
  362.      * @param     font   a font.
  363.      * @return    the screen metrics of the specified font in this toolkit.
  364.      * @since     JDK1.0
  365.      */
  366.     public abstract FontMetrics getFontMetrics(Font font);
  367.  
  368.     /**
  369.      * Synchronizes this toolkit's graphics state. Some window systems 
  370.      * may do buffering of graphics events. 
  371.      * <p>
  372.      * This method ensures that the display is up-to-date. It is useful
  373.      * for animation.
  374.      * @since     JDK1.0
  375.      */
  376.     public abstract void sync();
  377.  
  378.     /**
  379.      * The default toolkit.
  380.      */
  381.     private static Toolkit toolkit;
  382.  
  383.     /**
  384.      * Gets the default toolkit. 
  385.      * <p>
  386.      * If there is a system property named <code>"awt.toolkit"</code>, 
  387.      * that property is treated as the name of a class that is a subclass 
  388.      * of <code>Toolkit</code>. 
  389.      * <p>
  390.      * If the system property does not exist, then the default toolkit 
  391.      * used is the class named <code>"sun.awt.motif.MToolkit"</code>, 
  392.      * which is a motif implementation of the Abstract Window Toolkit. 
  393.      * @return    the default toolkit.
  394.      * @exception  AWTError  if a toolkit could not be found, or 
  395.      *                 if one could not be accessed or instantiated.
  396.      * @since     JDK1.0
  397.      */
  398.     public static synchronized Toolkit getDefaultToolkit() {
  399.     if (toolkit == null) {
  400.         String nm = System.getProperty("awt.toolkit", "sun.awt.motif.MToolkit");
  401.         try {
  402.         toolkit = (Toolkit)Class.forName(nm).newInstance();
  403.         } catch (ClassNotFoundException e) {
  404.         throw new AWTError("Toolkit not found: " + nm);
  405.         } catch (InstantiationException e) {
  406.         throw new AWTError("Could not instantiate Toolkit: " + nm);
  407.         } catch (IllegalAccessException e) {
  408.         throw new AWTError("Could not access Toolkit: " + nm);
  409.         }
  410.     }
  411.     return toolkit;
  412.     }
  413.  
  414.     /**
  415.      * Returns an image which gets pixel data from the specified file.
  416.      * @param     filename   the name of a file containing pixel data 
  417.      *                         in a recognized file format.
  418.      * @return    an image which gets its pixel data from 
  419.      *                         the specified file.
  420.      * @since     JDK1.0
  421.      */
  422.     public abstract Image getImage(String filename);
  423.  
  424.     /**
  425.      * Returns an image which gets pixel data from the specified URL.
  426.      * @param     url   the URL to use in fetching the pixel data.
  427.      * @return    an image which gets its pixel data from 
  428.      *                         the specified URL.
  429.      * @since     JDK1.0
  430.      */
  431.     public abstract Image getImage(URL url);
  432.  
  433.     /**
  434.      * Prepares an image for rendering. 
  435.      * <p>
  436.      * If the values of the width and height arguments are both 
  437.      * <code>-1</code>, this method prepares the image for rendering 
  438.      * on the default screen; otherwise, this method prepares an image 
  439.      * for rendering on the default screen at the specified width and height. 
  440.      * <p>
  441.      * The image data is downloaded asynchronously in another thread, 
  442.      * and an appropriately scaled screen representation of the image is 
  443.      * generated. 
  444.      * <p>
  445.      * This method is called by components <code>prepareImage</code> 
  446.      * methods. 
  447.      * <p>
  448.      * Information on the flags returned by this method can be found 
  449.      * with the definition of the <code>ImageObserver</code> interface. 
  450.  
  451.      * @param     image      the image for which to prepare a  
  452.      *                           screen representation.
  453.      * @param     width      the width of the desired screen 
  454.      *                           representation, or <code>-1</code>.
  455.      * @param     height     the height of the desired screen 
  456.      *                           representation, or <code>-1</code>.
  457.      * @param     observer   the <code>ImageObserver</code> 
  458.      *                           object to be notified as the 
  459.      *                           image is being prepared.
  460.      * @return    <code>true</code> if the image has already been 
  461.      *                 fully prepared; <code>false</code> otherwise.
  462.      * @see       java.awt.Component#prepareImage(java.awt.Image, 
  463.      *                 java.awt.image.ImageObserver)
  464.      * @see       java.awt.Component#prepareImage(java.awt.Image, 
  465.      *                 int, int, java.awt.image.ImageObserver)
  466.      * @see       java.awt.image.ImageObserver
  467.      * @since     JDK1.0
  468.      */
  469.     public abstract boolean prepareImage(Image image, int width, int height,
  470.                      ImageObserver observer);
  471.  
  472.     /**
  473.      * Indicates the construction status of a specified image that is
  474.      * being prepared for display.
  475.      * <p>
  476.      * If the values of the width and height arguments are both 
  477.      * <code>-1</code>, this method returns the construction status of 
  478.      * a screen representation of the specified image in this toolkit. 
  479.      * Otherwise, this method returns the construction status of a
  480.      * scaled representation of the image at the specified width 
  481.      * and height.
  482.      * <p>
  483.      * This method does not cause the image to begin loading. 
  484.      * An application must call <code>prepareImage</code> to force 
  485.      * the loading of an image.
  486.      * <p>
  487.      * This method is called by the component's <code>checkImage</code>
  488.      * methods.
  489.      * <p>
  490.      * Information on the flags returned by this method can be found
  491.      * with the definition of the <code>ImageObserver</code> interface.
  492.      * @param     image   the image whose status is being checked.
  493.      * @param     width   the width of the scaled version whose status is
  494.      *                 being checked, or <code>-1</code>.
  495.      * @param     height  the height of the scaled version whose status
  496.      *                 is being checked, or <code>-1</code>.
  497.      * @param     observer   the <code>ImageObserver</code> object to be
  498.      *                 notified as the image is being prepared.
  499.      * @return    the bitwise inclusive <strong>OR</strong> of the
  500.      *                 <code>ImageObserver</code> flags for the 
  501.      *                 image data that is currently available.
  502.      * @see       java.awt.Toolkit#prepareImage(java.awt.Image, 
  503.      *                 int, int, java.awt.image.ImageObserver)
  504.      * @see       java.awt.Component#checkImage(java.awt.Image, 
  505.      *                 java.awt.image.ImageObserver)
  506.      * @see       java.awt.Component#checkImage(java.awt.Image, 
  507.      *                 int, int, java.awt.image.ImageObserver)
  508.      * @see       java.awt.image.ImageObserver
  509.      * @since     JDK1.0
  510.      */
  511.     public abstract int checkImage(Image image, int width, int height,
  512.                    ImageObserver observer);
  513.  
  514.     /**
  515.      * Creates an image with the specified image producer.
  516.      * @param     producer the image producer to be used.
  517.      * @return    an image with the specified image producer.
  518.      * @see       java.awt.Image
  519.      * @see       java.awt.image.ImageProducer
  520.      * @see       java.awt.Component#createImage(java.awt.image.ImageProducer)
  521.      * @since     JDK1.0
  522.      */
  523.     public abstract Image createImage(ImageProducer producer);
  524.  
  525.     /**
  526.      * Creates an image which decodes the image stored in the specified
  527.      * byte array.
  528.      * <p>
  529.      * The data must be in some image format, such as GIF or JPEG, 
  530.      * that is supported by this toolkit.
  531.      * @param     imagedata   an array of bytes, representing 
  532.      *                         image data in a supported image format.
  533.      * @return    an image.
  534.      * @since     JDK1.1
  535.      */
  536.     public Image createImage(byte[] imagedata) {
  537.     return createImage(imagedata, 0, imagedata.length);
  538.     }
  539.  
  540.     /**
  541.      * Creates an image which decodes the image stored in the specified
  542.      * byte array, and at the specified offset and length.
  543.      * The data must be in some image format, such as GIF or JPEG, 
  544.      * that is supported by this toolkit. 
  545.      * @param     imagedata   an array of bytes, representing 
  546.      *                         image data in a supported image format.
  547.      * @param     imageoffset  the offset of the beginning 
  548.      *                         of the data in the array.
  549.      * @param     imagelength  the length of the data in the array.
  550.      * @return    an image.
  551.      * @since     JDK1.1
  552.      */
  553.     public abstract Image createImage(byte[] imagedata,
  554.                       int imageoffset,
  555.                       int imagelength);
  556.  
  557.     /**
  558.      * Gets a <code>PrintJob</code> object which is the result 
  559.      * of initiating a print operation on the toolkit's platform. 
  560.      * @return    a <code>PrintJob</code> object, or 
  561.      *                  <code>null</code> if the user 
  562.      *                  cancelled the print job.
  563.      * @see       java.awt.PrintJob
  564.      * @since     JDK1.1
  565.      */
  566.     public abstract PrintJob getPrintJob(Frame frame, String jobtitle, Properties props);
  567.  
  568.     /**
  569.      * Emits an audio beep.
  570.      * @since     JDK1.1
  571.      */
  572.     public abstract void beep();
  573.  
  574.     /**
  575.      * Gets an instance of the system clipboard which interfaces 
  576.      * with clipboard facilities provided by the native platform. 
  577.      * <p>
  578.      * This clipboard enables data transfer between Java programs 
  579.      * and native applications which use native clipboard facilities.
  580.      * @return    an instance of the system clipboard.
  581.      * @see       java.awt.datatransfer.Clipboard
  582.      * @since     JDK1.1
  583.      */
  584.     public abstract Clipboard getSystemClipboard();
  585.  
  586.     /**
  587.      * Determines which modifier key is the appropriate accelerator
  588.      * key for menu shortcuts.
  589.      * <p>
  590.      * Menu shortcuts, which are embodied in the 
  591.      * <code>MenuShortcut</code> class, are handled by the 
  592.      * <code>MenuBar</code> class.
  593.      * <p>
  594.      * By default, this method returns <code>Event.CTRL_MASK</code>.
  595.      * Toolkit implementations should override this method if the
  596.      * <b>Control</b> key isn't the correct key for accelerators.
  597.      * @return    the modifier mask on the <code>Event</code> class 
  598.      *                 that is used for menu shortcuts on this toolkit. 
  599.      * @see       java.awt.MenuBar
  600.      * @see       java.awt.MenuShortcut
  601.      * @since     JDK1.1
  602.      */
  603.     public int getMenuShortcutKeyMask() {
  604.         return Event.CTRL_MASK;
  605.     }
  606.  
  607.     /**
  608.      * Give native peers the ability to query the native container 
  609.      * given a native component (eg the direct parent may be lightweight).
  610.      */
  611.     protected static Container getNativeContainer(Component c) {
  612.     return c.getNativeContainer();
  613.     }
  614.  
  615.     /* Support for I18N: any visible strings should be stored in 
  616.      * lib/awt.properties.  The Properties list is stored here, so
  617.      * that only one copy is maintained.
  618.      */
  619.     private static Properties properties;
  620.     static {
  621.         String sep = File.separator;
  622.         File propsFile = new File(
  623.             System.getProperty("java.home") + sep + "lib" +
  624.             sep + "awt.properties");
  625.         properties = new Properties();
  626.     try {
  627.         FileInputStream in =
  628.         new FileInputStream(propsFile);
  629.         properties.load(new BufferedInputStream(in));
  630.         in.close();
  631.     } catch (Exception e) {
  632.             // No properties, defaults will be used.
  633.     }
  634.     }
  635.  
  636.     /**
  637.      * Gets a property with the specified key and default. 
  638.      * This method returns defaultValue if the property is not found.
  639.      */
  640.     public static String getProperty(String key, String defaultValue) {
  641.     String val = properties.getProperty(key);
  642.     return (val == null) ? defaultValue : val;
  643.     }
  644.  
  645.     /**
  646.      * Get the application's or applet's EventQueue instance.  
  647.      * Depending on the Toolkit implementation, different EventQueues 
  648.      * may be returned for different applets.  Applets should 
  649.      * therefore not assume that the EventQueue instance returned
  650.      * by this method will be shared by other applets or the system.
  651.      */
  652.     public final EventQueue getSystemEventQueue() {
  653.         SecurityManager security = System.getSecurityManager();
  654.         if (security != null) {
  655.       security.checkAwtEventQueueAccess();
  656.         }
  657.         return getSystemEventQueueImpl();
  658.     }
  659.  
  660.     /*
  661.      * Get the application's or applet's EventQueue instance, without
  662.      * checking access.  For security reasons, this can only be called 
  663.      * from a Toolkit subclass.  Implementations wishing to modify
  664.      * the default EventQueue support should subclass this method.
  665.      */
  666.     protected abstract EventQueue getSystemEventQueueImpl();
  667.  
  668.     /* Accessor method for use by AWT package routines. */
  669.     static EventQueue getEventQueue() {
  670.         return toolkit.getSystemEventQueueImpl();
  671.     }
  672. }
  673.  
  674.  
  675.  
  676. /**
  677.  * Implements the LightweightPeer interface for use in lightweight components
  678.  * that have no native window associated with them.  This gets created by
  679.  * default in Component so that Component and Container can be directly
  680.  * extended to create useful components written entirely in java.  These 
  681.  * components must be hosted somewhere higher up in the component tree by a 
  682.  * native container (such as a Frame).
  683.  *
  684.  * This implementation provides no useful semantics and serves only as a
  685.  * marker.  One could provide alternative implementations in java that do
  686.  * something useful for some of the other peer interfaces to minimize the
  687.  * native code.
  688.  *
  689.  * @author Timothy Prinzing
  690.  */
  691. class LightweightPeer implements java.awt.peer.LightweightPeer {
  692.  
  693.     public LightweightPeer(Component target) {
  694.     }
  695.  
  696.     public boolean isFocusTraversable() {
  697.     return false;
  698.     }
  699.  
  700.     public void setVisible(boolean b) {
  701.     }
  702.  
  703.     public void show() {
  704.     }
  705.  
  706.     public void hide() {
  707.     }
  708.  
  709.     public void setEnabled(boolean b) {
  710.     }
  711.  
  712.     public void enable() {
  713.     }
  714.  
  715.     public void disable() {
  716.     }
  717.  
  718.     public void paint(Graphics g) {
  719.     }
  720.  
  721.     public void repaint(long tm, int x, int y, int width, int height) {
  722.     }
  723.  
  724.     public void print(Graphics g) {
  725.     }
  726.  
  727.     public void setBounds(int x, int y, int width, int height) {
  728.     }
  729.  
  730.     public void reshape(int x, int y, int width, int height) {
  731.     }
  732.  
  733.     public boolean handleEvent(Event e) {
  734.     return false;
  735.     }
  736.  
  737.     public void handleEvent(java.awt.AWTEvent arg0) {
  738.     }
  739.  
  740.     public Dimension getPreferredSize() {
  741.     return new Dimension(1,1);
  742.     }
  743.  
  744.     public Dimension getMinimumSize() {
  745.     return new Dimension(1,1);
  746.     }
  747.  
  748.     public java.awt.Toolkit getToolkit() {
  749.     return null;
  750.     }
  751.  
  752.     public ColorModel getColorModel() {
  753.     return null;
  754.     }
  755.  
  756.     public Graphics getGraphics() {
  757.     return null;
  758.     }
  759.  
  760.     public FontMetrics    getFontMetrics(Font font) {
  761.     return null;
  762.     }
  763.  
  764.     public void dispose() {
  765.     // no native code
  766.     }
  767.  
  768.     public void setForeground(Color c) {
  769.     }
  770.  
  771.     public void setBackground(Color c) {
  772.     }
  773.  
  774.     public void setFont(Font f) {
  775.     }
  776.  
  777.     public void setCursor(Cursor cursor) {
  778.     }
  779.  
  780.     public void requestFocus() {
  781.     }
  782.  
  783.     public Image createImage(ImageProducer producer) {
  784.     return null;
  785.     }
  786.  
  787.     public Image createImage(int width, int height) {
  788.     return null;
  789.     }
  790.  
  791.     public boolean prepareImage(Image img, int w, int h, ImageObserver o) {
  792.     return false;
  793.     }
  794.  
  795.     public int    checkImage(Image img, int w, int h, ImageObserver o) {
  796.     return 0;
  797.     }
  798.  
  799.     public Dimension preferredSize() {
  800.     return getPreferredSize();
  801.     }
  802.  
  803.     public Dimension minimumSize() {
  804.     return getMinimumSize();
  805.     }
  806.  
  807.     public Point getLocationOnScreen() {
  808.     return null;
  809.     }
  810. }
  811.