Java プラットフォーム 1.2

javax.swing
クラス JApplet

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--javax.swing.JApplet

public class JApplet
extends Applet
implements Accessible, RootPaneContainer

拡張版の java.applet.Applet で、アプレットの子の前面に入力を重ね書きし、ペイント動作を行うサポート (glassPane を参照)、LayeredPane によって管理される特別な子のサポート (rootPane を参照)、および Swing MenuBar のサポートが追加されています。

JApplet クラスは java.applet.Applet と多少互換性のないところがあります。JApplet は JRootPane をその唯一の子として保持します。JApplet の子はどれでも contentPane を親に持たなければなりません。これは java.applet.Applet とは異なります。たとえば、java.applet.Applet に子を追加するには次のように記述します。

       applet.add(child);
 
一方、JApplet を使った場合には、代わりに JApplet の contentPane に子を追加する必要があります。
       applet.getContentPane().add(child);
 
LayoutManager の設定、コンポーネントの削除、子のリスト化などでも、同じことが言えます。これらのすべてのメソッドは通常、JApplet 自身ではなく contentPane() に送られます。contentPane() は常に null 以外です。これを null に設定しようとすると、JApplet が例外をスローする原因になります。デフォルトの contentPane() は、BorderLayout マネージャを contentPane に設定させます。

contentPane、glassPane、layeredPane の各プロパティの詳細は、JRootPane のドキュメントを参照してください。

標準の Look & Feel (L&F) 表現でこのコンポーネントが使用するキーボードのキーについては、JApplet のキーの割り当てを参照してください。

Netscape Communicator と Internet Explorer 4.0 は両方とも、アプレットが AWT システムイベントキューをアクセスしようとしたときに無条件で Java コンソールにエラーメッセージを出力します。Swing アプレットはこれを 1 回実行して、アクセスが許可されているかどうかをチェックします。製品アプレットで警告メッセージを防ぐには、JApplet RootPane の defeatSystemEventQueueCheck というクライアントプロパティを null 以外の、たとえば次のような値に設定します。

 JRootPane rp = myJApplet.getRootPane();
 rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);
 
将来のバージョンのブラウザでこの制限がなくなって、このような回避策が必要なくなることが期待されます。

警告: このクラスの直列化されたオブジェクトは、今後の Swing リリースと互換ではなくなる予定です。現在の直列化のサポートは、短期間の運用や、同じバージョンの Swing を実行するアプリケーション間の RMI に適しています。今後の Swing リリースでは、長期間の持続性をサポートする予定です。

関連項目:
直列化された形式

内部クラスの概要
protected  class JApplet.AccessibleJApplet
           
 
フィールドの概要
protected  AccessibleContext accessibleContext
           
protected  JRootPane rootPane
           
protected  boolean rootPaneCheckingEnabled
           
 
クラス java.awt.Component から継承したフィールド
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
コンストラクタの概要
JApplet()
          Swing アプレットのインスタンスを生成します。
 
メソッドの概要
protected  void addImpl(Component comp, Object constraints, int index)
          デフォルトでは、子はこのコンポーネントに直接追加されないので、代わりにその contentPane に追加されなければなりません。
protected  JRootPane createRootPane()
          コンストラクタメソッドによって呼び出され、デフォルトの rootPane を作成します。
 AccessibleContext getAccessibleContext()
          JApplet に関連付けられている AccessibleContext を取得します。
 Container getContentPane()
          アプレットの contentPane オブジェクトを返します。
 Component getGlassPane()
          アプレットの glassPane オブジェクトを返します。
 JMenuBar getJMenuBar()
          アプレットに設定されたメニューバーを返します。
 JLayeredPane getLayeredPane()
          アプレットの layeredPane オブジェクトを返します。
 JRootPane getRootPane()
          アプレットの rootPane オブジェクトを返します。
protected  boolean isRootPaneCheckingEnabled()
           
protected  String paramString()
          この JApplet の文字列表現を返します。
protected  void processKeyEvent(KeyEvent e)
           
 void setContentPane(Container contentPane)
          contentPane プロパティを設定します。
 void setGlassPane(Component glassPane)
          glassPane プロパティを設定します。
 void setJMenuBar(JMenuBar menuBar)
          アプレットのメニューバーを設定します。
 void setLayeredPane(JLayeredPane layeredPane)
          layeredPane プロパティを設定します。
 void setLayout(LayoutManager manager)
          デフォルトではこのコンポーネントのレイアウトは設定されないので、代わりにその contentPane のレイアウトが設定されなければなりません。
protected  void setRootPane(JRootPane root)
          rootPane プロパティを設定します。
protected  void setRootPaneCheckingEnabled(boolean enabled)
          true の場合は、add() と setLayout() への呼び出しが、例外がスローされる原因になります。
 void update(Graphics g)
          ただちに paint(g) を呼び出します。
 
クラス java.applet.Applet から継承したメソッド
destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, init, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
クラス java.awt.Panel から継承したメソッド
addNotify
 
クラス java.awt.Container から継承したメソッド
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, validate, validateTree
 
クラス java.awt.Component から継承したメソッド
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

フィールドの詳細

rootPane

protected JRootPane rootPane
関連項目:
getRootPane(), setRootPane(javax.swing.JRootPane)

rootPaneCheckingEnabled

protected boolean rootPaneCheckingEnabled
関連項目:
isRootPaneCheckingEnabled(), setRootPaneCheckingEnabled(boolean)

accessibleContext

protected AccessibleContext accessibleContext
コンストラクタの詳細

JApplet

public JApplet()
Swing アプレットのインスタンスを生成します。
メソッドの詳細

createRootPane

protected JRootPane createRootPane()
コンストラクタメソッドによって呼び出され、デフォルトの rootPane を作成します。

processKeyEvent

protected void processKeyEvent(KeyEvent e)
オーバーライド:
クラス Component 内の processKeyEvent

update

public void update(Graphics g)
ただちに paint(g) を呼び出します。このメソッドがオーバーライドされたので、バックグラウンドをクリアするための不要な呼び出しを防ぐことができました。
オーバーライド:
クラス Container 内の update

setJMenuBar

public void setJMenuBar(JMenuBar menuBar)
アプレットのメニューバーを設定します。
パラメータ:
menubar - アプレット内に配置中のメニューバー
関連項目:
getJMenuBar()

getJMenuBar

public JMenuBar getJMenuBar()
アプレットに設定されたメニューバーを返します。
関連項目:
setJMenuBar(javax.swing.JMenuBar)

isRootPaneCheckingEnabled

protected boolean isRootPaneCheckingEnabled()
戻り値:
add と setLayout をチェックする必要がある場合は true
関連項目:
addImpl(java.awt.Component, java.lang.Object, int), setLayout(java.awt.LayoutManager), setRootPaneCheckingEnabled(boolean)

setRootPaneCheckingEnabled

protected void setRootPaneCheckingEnabled(boolean enabled)
true の場合は、add() と setLayout() への呼び出しが、例外がスローされる原因になります。
関連項目:
addImpl(java.awt.Component, java.lang.Object, int), setLayout(java.awt.LayoutManager), isRootPaneCheckingEnabled()

addImpl

protected void addImpl(Component comp,
                       Object constraints,
                       int index)
デフォルトでは、子はこのコンポーネントに直接追加されないので、代わりにその contentPane に追加されなければなりません。たとえば、次のようになります。
 thisComponent.getContentPane().add(child)
 
このコンポーネントに直接追加しようとすると、実行時例外がスローされる原因になります。サブクラスはこの動作を無効にできます。
例外:
Error - rootPaneChecking を true に設定して呼び出された場合
オーバーライド:
クラス Container 内の addImpl
関連項目:
setRootPaneCheckingEnabled(boolean)

setLayout

public void setLayout(LayoutManager manager)
デフォルトではこのコンポーネントのレイアウトは設定されないので、代わりにその contentPane のレイアウトが設定されなければなりません。たとえば、次のようになります。
 thisComponent.getContentPane().setLayout(new BorderLayout())
 
このコンポーネントのレイアウトを設定しようとすると、実行時例外がスローされる原因になります。サブクラスはこの動作を無効にできます。
例外:
Error - rootPaneChecking を true に設定して呼び出された場合
オーバーライド:
クラス Container 内の setLayout
関連項目:
setRootPaneCheckingEnabled(boolean)

getRootPane

public JRootPane getRootPane()
アプレットの rootPane オブジェクトを返します。
定義:
インタフェース RootPaneContainer 内の getRootPane
関連項目:
setRootPane(javax.swing.JRootPane), RootPaneContainer.getRootPane()

setRootPane

protected void setRootPane(JRootPane root)
rootPane プロパティを設定します。このメソッドはコンストラクタによって呼び出されます。
パラメータ:
root - アプレットの rootPane オブジェクト
関連項目:
getRootPane()

getContentPane

public Container getContentPane()
アプレットの contentPane オブジェクトを返します。
定義:
インタフェース RootPaneContainer 内の getContentPane
関連項目:
setContentPane(java.awt.Container), RootPaneContainer.getContentPane()

setContentPane

public void setContentPane(Container contentPane)
contentPane プロパティを設定します。このメソッドはコンストラクタによって呼び出されます。
定義:
インタフェース RootPaneContainer 内の setContentPane
パラメータ:
contentPane - アプレットの contentPane オブジェクト
例外:
IllegalComponentStateException - (実行時例外) このコンテンツ区画パラメータが null の場合
関連項目:
getContentPane(), RootPaneContainer.setContentPane(java.awt.Container)

getLayeredPane

public JLayeredPane getLayeredPane()
アプレットの layeredPane オブジェクトを返します。
定義:
インタフェース RootPaneContainer 内の getLayeredPane
例外:
IllegalComponentStateException - (実行時例外) この階層化区画パラメータが null の場合
関連項目:
setLayeredPane(javax.swing.JLayeredPane), RootPaneContainer.getLayeredPane()

setLayeredPane

public void setLayeredPane(JLayeredPane layeredPane)
layeredPane プロパティを設定します。このメソッドはコンストラクタによって呼び出されます。
定義:
インタフェース RootPaneContainer 内の setLayeredPane
パラメータ:
layeredPane - アプレットの layeredPane オブジェクト
関連項目:
getLayeredPane(), RootPaneContainer.setLayeredPane(javax.swing.JLayeredPane)

getGlassPane

public Component getGlassPane()
アプレットの glassPane オブジェクトを返します。
定義:
インタフェース RootPaneContainer 内の getGlassPane
関連項目:
setGlassPane(java.awt.Component), RootPaneContainer.getGlassPane()

setGlassPane

public void setGlassPane(Component glassPane)
glassPane プロパティを設定します。このメソッドはコンストラクタによって呼び出されます。
定義:
インタフェース RootPaneContainer 内の setGlassPane
パラメータ:
glassPane - アプレットの glassPane オブジェクト
関連項目:
getGlassPane(), RootPaneContainer.setGlassPane(java.awt.Component)

paramString

protected String paramString()
この JApplet の文字列表現を返します。このメソッドは、デバッグ専用であり、返される文字列の内容および形式は実装によって異なります。返される文字列は空の場合がありますが、null にはなりません。

JFC コンポーネントの新しい側面についての情報を返すには、paramString() をオーバーライドします。

戻り値:
この JApplet の文字列表現
オーバーライド:
クラス Container 内の paramString

getAccessibleContext

public AccessibleContext getAccessibleContext()
JApplet に関連付けられている AccessibleContext を取得します。
定義:
インタフェース Accessible 内の getAccessibleContext
戻り値:
JApplet の AccessibleContext

Java プラットフォーム 1.2

バグや機能要求の報告
新しい javadoc の表示についてのコメントやご提案
Java は、米国およびその他の国における米国 Sun Microsystems, Inc. の商標もしくは登録商標です。
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.