KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > awt > Toolkit

java.awt
Class Toolkit

java.lang.Object
  extended by java.awt.Toolkit
See Also:
Top Examples, Source Code, Window

public void addAWTEventListener(AWTEventListener listener,
                                long eventMask)
See Also:
AWTEventListenerProxy, AWTPermission, AWTEvent, SecurityManager.checkPermission(java.security.Permission), getAWTEventListeners(), removeAWTEventListener(java.awt.event.AWTEventListener), SecurityException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void addPropertyChangeListener(String name,
                                      PropertyChangeListener pcl)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract void beep()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract int checkImage(Image image,
                               int width,
                               int height,
                               ImageObserver observer)
See Also:
Component.checkImage(java.awt.Image, java.awt.image.ImageObserver), prepareImage(java.awt.Image, int, int, java.awt.image.ImageObserver)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.ButtonPeer createButton(Button target)
                                                  throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.CanvasPeer createCanvas(Canvas target)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.CheckboxPeer createCheckbox(Checkbox target)
                                                      throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target)
                                                                      throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.ChoicePeer createChoice(Choice target)
                                                  throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected java.awt.peer.LightweightPeer createComponent(Component target)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Cursor createCustomCursor(Image cursor,
                                 Point hotSpot,
                                 String name)
                          throws IndexOutOfBoundsException,
                                 HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.DialogPeer createDialog(Dialog target)
                                                  throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public <T extends DragGestureRecognizer> T createDragGestureRecognizer(Class<T> abstractRecognizerClass,
                                                                       DragSource ds,
                                                                       Component c,
                                                                       int srcActions,
                                                                       DragGestureListener dgl)
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract java.awt.dnd.peer.DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge)
                                                                             throws InvalidDnDOperationException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.FileDialogPeer createFileDialog(FileDialog target)
                                                          throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.FramePeer createFrame(Frame target)
                                                throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Image createImage(byte[] imagedata)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract Image createImage(byte[] imagedata,
                                  int imageoffset,
                                  int imagelength)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[491]Load a disk image
By Anonymous on 2004/08/11 20:07:30  Rate
Image i = createImage ( "D:/Eigene_Dateien/Bilder/Volleyball/volley.jpg" ) ;

public abstract Image createImage(ImageProducer producer)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract Image createImage(String filename)
See Also:
getImage(java.lang.String)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract Image createImage(URL url)
See Also:
getImage(java.net.URL)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.LabelPeer createLabel(Label target)
                                                throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.ListPeer createList(List target)
                                              throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.MenuPeer createMenu(Menu target)
                                              throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.MenuBarPeer createMenuBar(MenuBar target)
                                                    throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.MenuItemPeer createMenuItem(MenuItem target)
                                                      throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.PanelPeer createPanel(Panel target)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.PopupMenuPeer createPopupMenu(PopupMenu target)
                                                        throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.ScrollbarPeer createScrollbar(Scrollbar target)
                                                        throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.ScrollPanePeer createScrollPane(ScrollPane target)
                                                          throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.TextAreaPeer createTextArea(TextArea target)
                                                      throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.TextFieldPeer createTextField(TextField target)
                                                        throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract java.awt.peer.WindowPeer createWindow(Window target)
                                                  throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected final Map<String,Object> desktopProperties
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected final PropertyChangeSupport desktopPropsSupport
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public AWTEventListener[] getAWTEventListeners()
See Also:
AWTEventListenerProxy, AWTPermission, AWTEvent, SecurityManager.checkPermission(java.security.Permission), removeAWTEventListener(java.awt.event.AWTEventListener), addAWTEventListener(java.awt.event.AWTEventListener, long), SecurityException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public AWTEventListener[] getAWTEventListeners(long eventMask)
See Also:
AWTEventListenerProxy, AWTPermission, AWTEvent, SecurityManager.checkPermission(java.security.Permission), removeAWTEventListener(java.awt.event.AWTEventListener), addAWTEventListener(java.awt.event.AWTEventListener, long), SecurityException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Dimension getBestCursorSize(int preferredWidth,
                                   int preferredHeight)
                            throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract ColorModel getColorModel()
                                  throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static Toolkit getDefaultToolkit()
See Also:
AWTError
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final Object getDesktopProperty(String propertyName)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


@Deprecated
public abstract String[] getFontList()
See Also:
GraphicsEnvironment.getAvailableFontFamilyNames()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


@Deprecated
public abstract FontMetrics getFontMetrics(Font font)
See Also:
GraphicsEnvironment.getScreenDevices(), Font.getLineMetrics(java.lang.String, java.awt.font.FontRenderContext), LineMetrics
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


@Deprecated
protected abstract java.awt.peer.FontPeer getFontPeer(String name,
                                                                 int style)
See Also:
GraphicsEnvironment.getAllFonts(), Font
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract Image getImage(String filename)
See Also:
createImage(java.lang.String)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract Image getImage(URL url)
See Also:
createImage(java.net.URL)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1910]Download an image
By Anonymous on 2007/08/05 21:09:49  Rate
Image img = Toolkit.getDefaultToolkit (  ) .getImage ( URL or file path ) ; 
  
  
 The Toolkit is a class in the java.awt package that provides various resources and tools for the display system. One of the Toolkit methods is getImage (  )  that functions much like the getImage (  )  method in the Applet class. It is overloaded to take either a String filename parameter specifying the location of the image file or a URL parameter identifying the image file. 
  
  
 Before calling getImage (  ) , one must have a reference to the Toolkit instance in use. The static method Toolkit.getDefaultToolkit (  )  returns a reference to that Toolkit. 
  
  
 You can obtain an image from a JAR file by using the getResource (  )  static method from the Class class: 
  
  
   URL url = this.getClass (  ) .getResource ( "anImage.gif" ) ; 
   Image img = Toolkit.getDefaultToolkit (  ) .getImage ( url ) ; 
  
  
 or 
  
  
   URL url = YourClass.class.getResource ( "anImage.gif" ) ; 
   Image img = Toolkit.getDefaultToolkit (  ) .getImage ( url ) ; 
  
  
 Note: Image is an abstract class so you are actually loading an instance of a concrete subclass of Image with the getImage (  )  methods above. However, you always treat the object as an instance of Image, i.e. you only have access to its methods.


public boolean getLockingKeyState(int keyCode)
                           throws UnsupportedOperationException
See Also:
GraphicsEnvironment.isHeadless(), HeadlessException, IllegalArgumentException, VK_KANA_LOCK, VK_SCROLL_LOCK, VK_NUM_LOCK, VK_CAPS_LOCK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int getMaximumCursorColors()
                           throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int getMenuShortcutKeyMask()
                           throws HeadlessException
See Also:
MenuShortcut, MenuBar, GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected java.awt.peer.MouseInfoPeer getMouseInfoPeer()
See Also:
MouseInfo, UnsupportedOperationException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected static Container getNativeContainer(Component c)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public PrintJob getPrintJob(Frame frame,
                            String jobtitle,
                            JobAttributes jobAttributes,
                            PageAttributes pageAttributes)
See Also:
RuntimePermission, GraphicsEnvironment.isHeadless(), SecurityException, IllegalArgumentException, NullPointerException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract PrintJob getPrintJob(Frame frame,
                                     String jobtitle,
                                     Properties props)
See Also:
RuntimePermission, GraphicsEnvironment.isHeadless(), SecurityException, NullPointerException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static String getProperty(String key,
                                 String defaultValue)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public PropertyChangeListener[] getPropertyChangeListeners()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Insets getScreenInsets(GraphicsConfiguration gc)
                       throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract int getScreenResolution()
                                 throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract Dimension getScreenSize()
                                 throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless(), GraphicsDevice.getDisplayMode(), GraphicsConfiguration.getBounds()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1241]Adjust frame size
By Anonymous on 2005/01/04 18:37:06  Rate
import java.awt.Container; 
 import java.awt.Toolkit; 
 import java.awt.Dimension 
 import javax.swing.JFrame; 
  
  
 /* Estamos herdando m??todos e atributos da classe JFrame */ 
 public class Demonstracao extends JFrame  {  
  
  
 /* Declara????o das a????es a serem executadas pelo contrutor default */ 
 public Demonstracao (  )   {  
   /* Passa o argumento que ir?? definir o t??tulo da janela ao construtor da superclasse JFrame*/ 
   super ( "Classe de demonstracao" ) ; 
  
  
   /* Aqui atribuimos a refer??ncia container o m??todo que retorna o painel de conte??do de JFrame */ 
   Container container = getContentPane (  ) ; 
  }  
  
  
 /* Aqui iniciamos o corpo do m??todo main */ 
 public static void main  ( String args [  ]  )   {  
  
  
   /* Instanciamos a classe Demonstracao, que possui todos os m??todos e atribuitos de JFrame */ 
   Demonstracao janela = new Demonstracao (  ) ; 
  
  
   /* Invocamos o m??todo que ir?? definir o tamanho da janela da classe Demonstracao */ 
   janela.setSize ( 250,250 ) ; 
  
  
   /* Aqui atribuimos uma ref??ncia para a classe Dimension que ir?? receber e encapsular os valores retornados pelo m??todo getScreenSize, primeiro invocamos o m??todo que getDefaultToolkit que ir?? nos retornar um objeto default toolkit e nos possibilitar utiliza????o do m??todo getScreenSize (  )  para retornar o valor da resolu????o de tela em pixels; */
   Dimension tela = Toolkit.getDefaultToolkit (  ) .getScreenSize (  ) ; 
  
  
   /* Aqui estamos utilizando a refer??ncia com os m??todos de largura ( Width )  e altura ( Height ) , diminuimos pelo tamanho do JFrame e dividimos por 2, fazendo o casting para inteiro, para que possamos ter a posi????o exata e central da tela. 
   int largura =  ( int )   ( tela.getWidth (  )  - 250 )  / 2; 
   int altura =  ( int )   ( tela.getHeight (  )  - 250 )  / 2; 
  
  
   /* Por fim utilizamos o m??todo herdado do JFrame para definir a posi????o do objeto na tela, ?? partir dos valores obtidos acima */ 
   janela.setLocation ( largura,altura ) ; 
    
   /* M??todo respons??vel por definir a "visibilidade" da janela na tela */ 
   janela.setVisible ( true ) ; 
  }  
  
  
  } 


public abstract Clipboard getSystemClipboard()
                                      throws HeadlessException
See Also:
AWTPermission, Reader, DataFlavor.plainTextFlavor, DataFlavor.stringFlavor, StringSelection, GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final EventQueue getSystemEventQueue()
See Also:
AWTPermission, SecurityManager.checkAwtEventQueueAccess(), SecurityException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected abstract EventQueue getSystemEventQueueImpl()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Clipboard getSystemSelection()
                             throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless(), AWTPermission, JTextComponent, TextComponent, FocusEvent.FOCUS_LOST, FocusEvent.FOCUS_GAINED, FocusListener
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected void initializeDesktopProperties()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isDynamicLayoutActive()
                              throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless(), getDesktopProperty(String propertyName), isDynamicLayoutSet(), setDynamicLayout(boolean dynamic)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected boolean isDynamicLayoutSet()
                              throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless(), getDesktopProperty(String propertyName), isDynamicLayoutActive(), setDynamicLayout(boolean dynamic)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isFrameStateSupported(int state)
                              throws HeadlessException
See Also:
Frame.setExtendedState(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected Object lazilyLoadDesktopProperty(String name)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected void loadSystemColors(int[] systemColors)
                         throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract Map<TextAttribute,?> mapInputMethodHighlight(InputMethodHighlight highlight)
                                                      throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract boolean prepareImage(Image image,
                                     int width,
                                     int height,
                                     ImageObserver observer)
See Also:
Component.prepareImage(java.awt.Image, java.awt.image.ImageObserver)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void removeAWTEventListener(AWTEventListener listener)
See Also:
AWTEventListenerProxy, AWTPermission, AWTEvent, SecurityManager.checkPermission(java.security.Permission), getAWTEventListeners(), addAWTEventListener(java.awt.event.AWTEventListener, long), SecurityException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void removePropertyChangeListener(String name,
                                         PropertyChangeListener pcl)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected final void setDesktopProperty(String name,
                                        Object newValue)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setDynamicLayout(boolean dynamic)
                      throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless(), getDesktopProperty(String propertyName), isDynamicLayoutActive(), isDynamicLayoutSet()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setLockingKeyState(int keyCode,
                               boolean on)
                        throws UnsupportedOperationException
See Also:
GraphicsEnvironment.isHeadless(), HeadlessException, IllegalArgumentException, VK_KANA_LOCK, VK_SCROLL_LOCK, VK_NUM_LOCK, VK_CAPS_LOCK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract void sync()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Toolkit()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Words from our friends at WHS: Read more about web hosting tutorials and reviews to choose the best service suitable for your web projects.

Popular Tags