📄 toolkit.java
字号:
} catch (IllegalAccessException e) {
throw new AWTError("Could not access Toolkit: " + nm);
}
}
return toolkit;
}
/**
* Returns an image which gets pixel data from the specified file.
* @param filename the name of a file containing pixel data
* in a recognized file format.
* @return an image which gets its pixel data from
* the specified file.
* @since JDK1.0
*/
public abstract Image getImage(String filename);
/**
* Returns an image which gets pixel data from the specified URL.
* @param url the URL to use in fetching the pixel data.
* @return an image which gets its pixel data from
* the specified URL.
* @since JDK1.0
*/
public abstract Image getImage(URL url);
/**
* Prepares an image for rendering.
* <p>
* If the values of the width and height arguments are both
* <code>-1</code>, this method prepares the image for rendering
* on the default screen; otherwise, this method prepares an image
* for rendering on the default screen at the specified width and height.
* <p>
* The image data is downloaded asynchronously in another thread,
* and an appropriately scaled screen representation of the image is
* generated.
* <p>
* This method is called by components <code>prepareImage</code>
* methods.
* <p>
* Information on the flags returned by this method can be found
* with the definition of the <code>ImageObserver</code> interface.
* @param image the image for which to prepare a
* screen representation.
* @param width the width of the desired screen
* representation, or <code>-1</code>.
* @param height the height of the desired screen
* representation, or <code>-1</code>.
* @param observer the <code>ImageObserver</code>
* object to be notified as the
* image is being prepared.
* @return <code>true</code> if the image has already been
* fully prepared; <code>false</code> otherwise.
* @see java.awt.Component#prepareImage(java.awt.Image,
* java.awt.image.ImageObserver)
* @see java.awt.Component#prepareImage(java.awt.Image,
* int, int, java.awt.image.ImageObserver)
* @see java.awt.image.ImageObserver
* @since JDK1.0
*/
public abstract boolean prepareImage(Image image, int width, int height,
ImageObserver observer);
/**
* Indicates the construction status of a specified image that is
* being prepared for display.
* <p>
* If the values of the width and height arguments are both
* <code>-1</code>, this method returns the construction status of
* a screen representation of the specified image in this toolkit.
* Otherwise, this method returns the construction status of a
* scaled representation of the image at the specified width
* and height.
* <p>
* This method does not cause the image to begin loading.
* An application must call <code>prepareImage</code> to force
* the loading of an image.
* <p>
* This method is called by the component's <code>checkImage</code>
* methods.
* <p>
* Information on the flags returned by this method can be found
* with the definition of the <code>ImageObserver</code> interface.
* @param image the image whose status is being checked.
* @param width the width of the scaled version whose status is
* being checked, or <code>-1</code>.
* @param height the height of the scaled version whose status
* is being checked, or <code>-1</code>.
* @param observer the <code>ImageObserver</code> object to be
* notified as the image is being prepared.
* @return the bitwise inclusive <strong>OR</strong> of the
* <code>ImageObserver</code> flags for the
* image data that is currently available.
* @see java.awt.Toolkit#prepareImage(java.awt.Image,
* int, int, java.awt.image.ImageObserver)
* @see java.awt.Component#checkImage(java.awt.Image,
* java.awt.image.ImageObserver)
* @see java.awt.Component#checkImage(java.awt.Image,
* int, int, java.awt.image.ImageObserver)
* @see java.awt.image.ImageObserver
* @since JDK1.0
*/
public abstract int checkImage(Image image, int width, int height,
ImageObserver observer);
/**
* Creates an image with the specified image producer.
* @param producer the image producer to be used.
* @return an image with the specified image producer.
* @see java.awt.Image
* @see java.awt.image.ImageProducer
* @see java.awt.Component#createImage(java.awt.image.ImageProducer)
* @since JDK1.0
*/
public abstract Image createImage(ImageProducer producer);
/**
* Creates an image which decodes the image stored in the specified
* byte array.
* <p>
* The data must be in some image format, such as GIF or JPEG,
* that is supported by this toolkit.
* @param imagedata an array of bytes, representing
* image data in a supported image format.
* @return an image.
* @since JDK1.1
*/
public Image createImage(byte[] imagedata) {
return createImage(imagedata, 0, imagedata.length);
}
/**
* Creates an image which decodes the image stored in the specified
* byte array, and at the specified offset and length.
* The data must be in some image format, such as GIF or JPEG,
* that is supported by this toolkit.
* @param imagedata an array of bytes, representing
* image data in a supported image format.
* @param imageoffset the offset of the beginning
* of the data in the array.
* @param imagelength the length of the data in the array.
* @return an image.
* @since JDK1.1
*/
public abstract Image createImage(byte[] imagedata,
int imageoffset,
int imagelength);
/**
* Gets a <code>PrintJob</code> object which is the result
* of initiating a print operation on the toolkit's platform.
* @return a <code>PrintJob</code> object, or
* <code>null</code> if the user
* cancelled the print job.
* @see java.awt.PrintJob
* @since JDK1.1
*/
public abstract PrintJob getPrintJob(Frame frame, String jobtitle, Properties props);
/**
* Emits an audio beep.
* @since JDK1.1
*/
public abstract void beep();
/**
* Gets an instance of the system clipboard which interfaces
* with clipboard facilities provided by the native platform.
* <p>
* This clipboard enables data transfer between Java programs
* and native applications which use native clipboard facilities.
* @return an instance of the system clipboard.
* @see java.awt.datatransfer.Clipboard
* @since JDK1.1
*/
public abstract Clipboard getSystemClipboard();
/**
* Determines which modifier key is the appropriate accelerator
* key for menu shortcuts.
* <p>
* Menu shortcuts, which are embodied in the
* <code>MenuShortcut</code> class, are handled by the
* <code>MenuBar</code> class.
* <p>
* By default, this method returns <code>Event.CTRL_MASK</code>.
* Toolkit implementations should override this method if the
* <b>Control</b> key isn't the correct key for accelerators.
* @return the modifier mask on the <code>Event</code> class
* that is used for menu shortcuts on this toolkit.
* @see java.awt.MenuBar
* @see java.awt.MenuShortcut
* @since JDK1.1
*/
public int getMenuShortcutKeyMask() {
return Event.CTRL_MASK;
}
/**
* Give native peers the ability to query the native container
* given a native component (eg the direct parent may be lightweight).
*/
protected static Container getNativeContainer(Component c) {
return c.getNativeContainer();
}
/* Support for I18N: any visible strings should be stored in
* lib/awt.properties. The Properties list is stored here, so
* that only one copy is maintained.
*/
private static Properties properties;
static {
String sep = File.separator;
File propsFile = new File(
System.getProperty("java.home") + sep + "lib" +
sep + "awt.properties");
properties = new Properties();
try {
FileInputStream in =
new FileInputStream(propsFile);
properties.load(new BufferedInputStream(in));
in.close();
} catch (Exception e) {
// No properties, defaults will be used.
}
}
/**
* Gets a property with the specified key and default.
* This method returns defaultValue if the property is not found.
*/
public static String getProperty(String key, String defaultValue) {
String val = properties.getProperty(key);
return (val == null) ? defaultValue : val;
}
/**
* Get the application's or applet's EventQueue instance.
* Depending on the Toolkit implementation, different EventQueues
* may be returned for different applets. Applets should
* therefore not assume that the EventQueue instance returned
* by this method will be shared by other applets or the system.
*/
public final EventQueue getSystemEventQueue() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkAwtEventQueueAccess();
}
return getSystemEventQueueImpl();
}
/*
* Get the application's or applet's EventQueue instance, without
* checking access. For security reasons, this can only be called
* from a Toolkit subclass. Implementations wishing to modify
* the default EventQueue support should subclass this method.
*/
protected abstract EventQueue getSystemEventQueueImpl();
/* Accessor method for use by AWT package routines. */
static EventQueue getEventQueue() {
return toolkit.getSystemEventQueueImpl();
}
}
/**
* Implements the LightweightPeer interface for use in lightweight components
* that have no native window associated with them. This gets created by
* default in Component so that Component and Container can be directly
* extended to create useful components written entirely in java. These
* components must be hosted somewhere higher up in the component tree by a
* native container (such as a Frame).
*
* This implementation provides no useful semantics and serves only as a
* marker. One could provide alternative implementations in java that do
* something useful for some of the other peer interfaces to minimize the
* native code.
*
* @author Timothy Prinzing
*/
class LightweightPeer implements java.awt.peer.LightweightPeer {
public LightweightPeer(Component target) {
}
public boolean isFocusTraversable() {
return false;
}
public void setVisible(boolean b) {
}
public void show() {
}
public void hide() {
}
public void setEnabled(boolean b) {
}
public void enable() {
}
public void disable() {
}
public void paint(Graphics g) {
}
public void repaint(long tm, int x, int y, int width, int height) {
}
public void print(Graphics g) {
}
public void setBounds(int x, int y, int width, int height) {
}
public void reshape(int x, int y, int width, int height) {
}
public boolean handleEvent(Event e) {
return false;
}
public void handleEvent(java.awt.AWTEvent arg0) {
}
public Dimension getPreferredSize() {
return new Dimension(1,1);
}
public Dimension getMinimumSize() {
return new Dimension(1,1);
}
public java.awt.Toolkit getToolkit() {
return null;
}
public ColorModel getColorModel() {
return null;
}
public Graphics getGraphics() {
return null;
}
public FontMetrics getFontMetrics(Font font) {
return null;
}
public void dispose() {
// no native code
}
public void setForeground(Color c) {
}
public void setBackground(Color c) {
}
public void setFont(Font f) {
}
public void setCursor(Cursor cursor) {
}
public void requestFocus() {
}
public Image createImage(ImageProducer producer) {
return null;
}
public Image createImage(int width, int height) {
return null;
}
public boolean prepareImage(Image img, int w, int h, ImageObserver o) {
return false;
}
public int checkImage(Image img, int w, int h, ImageObserver o) {
return 0;
}
public Dimension preferredSize() {
return getPreferredSize();
}
public Dimension minimumSize() {
return getMinimumSize();
}
public Point getLocationOnScreen() {
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -