Source for gnu.java.awt.peer.swing.SwingToolkit

   1: /* SwingToolkit.java -- A base toolkit for Swing peers
   2:    Copyright (C) 2006 Free Software Foundation, Inc.
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10: 
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: 
  39: package gnu.java.awt.peer.swing;
  40: 
  41: import java.awt.Button;
  42: import java.awt.Canvas;
  43: import java.awt.Label;
  44: import java.awt.Menu;
  45: import java.awt.MenuBar;
  46: import java.awt.MenuItem;
  47: import java.awt.Panel;
  48: import java.awt.TextField;
  49: import java.awt.peer.ButtonPeer;
  50: import java.awt.peer.CanvasPeer;
  51: import java.awt.peer.LabelPeer;
  52: import java.awt.peer.MenuBarPeer;
  53: import java.awt.peer.MenuItemPeer;
  54: import java.awt.peer.MenuPeer;
  55: import java.awt.peer.PanelPeer;
  56: import java.awt.peer.TextFieldPeer;
  57: 
  58: import gnu.java.awt.ClasspathToolkit;
  59: 
  60: /**
  61:  * A base implementation for {@link java.awt.Toolkit} that provides the
  62:  * Swing based widgets. Concrete implementations still must provide the
  63:  * remaining abstract methods.
  64:  *
  65:  * @author Roman Kennke (kennke@aicas.com)
  66:  */
  67: public abstract class SwingToolkit extends ClasspathToolkit
  68: {
  69: 
  70:   /**
  71:    * Creates a SwingButtonPeer.
  72:    *
  73:    * @param button the AWT button
  74:    *
  75:    * @return the Swing button peer
  76:    */
  77:   protected ButtonPeer createButton(Button button)
  78:   {
  79:     return new SwingButtonPeer(button);
  80:   }
  81: 
  82:   /**
  83:    * Creates a SwingCanvasPeer.
  84:    *
  85:    * @param canvas the AWT canvas
  86:    *
  87:    * @return the Swing canvas peer
  88:    */
  89:   protected CanvasPeer createCanvas(Canvas canvas)
  90:   {
  91:     return new SwingCanvasPeer(canvas);
  92:   }
  93: 
  94:   /**
  95:    * Creates a SwingLabelPeer.
  96:    *
  97:    * @param label the AWT label
  98:    *
  99:    * @return the Swing label peer
 100:    */
 101:   protected LabelPeer createLabel(Label label)
 102:   {
 103:     return new SwingLabelPeer(label);
 104:   }
 105: 
 106:   /**
 107:    * Creates a SwingMenuPeer.
 108:    *
 109:    * @param menu the AWT menu
 110:    *
 111:    * @return the Swing menu peer
 112:    */
 113:   protected MenuPeer createMenu(Menu menu)
 114:   {
 115:     return new SwingMenuPeer(menu);
 116:   }
 117: 
 118:   /**
 119:    * Creates a SwingMenuBarPeer.
 120:    *
 121:    * @param menuBar the AWT menubar
 122:    *
 123:    * @return the Swing menu bar peer
 124:    */
 125:   protected MenuBarPeer createMenuBar(MenuBar menuBar)
 126:   {
 127:     return new SwingMenuBarPeer(menuBar);
 128:   }
 129: 
 130:   /**
 131:    * Creates a SwingMenuItemPeer.
 132:    *
 133:    * @param menuItem the AWT menu item
 134:    *
 135:    * @return the Swing menu item peer
 136:    */
 137:   protected MenuItemPeer createMenuItem(MenuItem menuItem)
 138:   {
 139:     return new SwingMenuItemPeer(menuItem);
 140:   }
 141: 
 142:   /**
 143:    * Creates a SwingPanelPeer.
 144:    *
 145:    * @param panel the AWT panel
 146:    *
 147:    * @return the Swing panel peer
 148:    */
 149:   protected PanelPeer createPanel(Panel panel)
 150:   {
 151:     return new SwingPanelPeer(panel);
 152:   }
 153: 
 154:   /**
 155:    * Creates a SwingTextFieldPeer.
 156:    *
 157:    * @param textField the AWT text field
 158:    *
 159:    * @return the Swing text field peer
 160:    */
 161:   protected TextFieldPeer createTextField(TextField textField)
 162:   {
 163:     return new SwingTextFieldPeer(textField);
 164:   }
 165: }