public abstract class BasicTextUI extends TextUI implements ViewFactory
 テキスト・コンポーネントのLook & Feelの基礎です。 このクラスは、JTextComponentの拡張のためのLook & Feelを作成するときに便利な、エディタ・ビューおよびコントローラの基本的なサービスを提供します。 
 
 ほとんどの状態は関連付けられたJTextComponentにバウンド・プロパティとして保持されており、UIはさまざまなプロパティのデフォルト値をインストールします。 このデフォルトは、すべてのプロパティのために何かをインストールします。 ただし通常は、LAF実装が追加の作業を行います。 少なくとも、LAFは一般的にキー・バインディングをインストールします。 
 
 また、JTextComponentに関連付けられたDocumentがAbstractDocumentのサブクラスである場合、このクラスはいくつかの並行サポートも提供します。 ViewまたはView階層へのアクセスは、モデルを変更するスレッドとSwingイベント・スレッド(レンダリング、モデルとビュー座標変換などを行う)との間で直列化されます。 ルート・ビューにアクセスするときは、最初にAbstractDocumentで読取りロックを獲得して、そのロックをfinallyブロックで解放するようにしてください。 
 
 定義する必要がある重要なメソッドは、UIManagerからデフォルトを取り出すために使用されるキーの基礎として使用される、getPropertyPrefix()メソッドです。 文字列は、名前の特定のLAF部分(例、Metal、Motif、など)を含まないTextUI (例、TextField、TextArea、など)のタイプを反映する必要があります。 
 
モデルのビューを構築するには、次に示す方法のいずれかを使います。
create(javax.swing.text.Element)メソッドを実装し直します。 
 
 警告: このクラスの直列化されたオブジェクトは、今後のSwingリリースとの互換性がなくなる予定です。 現在の直列化のサポートは、短期間の格納や、同じバージョンのSwingを実行するアプリケーション間のRMIに適しています。 1.4以降、すべてのJavaBeans™用の長期間の格納サポートがjava.beansパッケージに追加されています。 XMLEncoderを参照してください。 
| 修飾子と型 | クラス | 説明 | 
|---|---|---|
| static class  | BasicTextUI.BasicCaret | |
| static class  | BasicTextUI.BasicHighlighter | 
| コンストラクタ | 説明 | 
|---|---|
| BasicTextUI() | 新しいUIを作成します。 | 
| 修飾子と型 | メソッド | 説明 | 
|---|---|---|
| View | create(Element elem) | 要素のビューを作成します。 | 
| View | create(Element elem, int p0, int p1) | 要素のビューを作成します。 | 
| protected Caret | createCaret() | キャレットに使用するオブジェクトを作成します。 | 
| protected Highlighter | createHighlighter() | ハイライトを追加するために使用するオブジェクトを作成します。 | 
| protected Keymap | createKeymap() | テキスト・コンポーネントに使用するキーマップを作成し、それに必要なバインディングをインストールします。 | 
| void | damageRange(JTextComponent tc, int p0, int p1) | モデル内の指定された一部分に対応するビューの部分が描画し直されるようにします。 | 
| void | damageRange(JTextComponent t, int p0, int p1, Position.Bias p0Bias, Position.Bias p1Bias) | モデル内の指定された一部分に対応するビューの部分が描画し直されるようにします。 | 
| protected JTextComponent | getComponent() | このUI実装に関連付けられたテキスト・コンポーネントを取得します。 | 
| EditorKit | getEditorKit(JTextComponent tc) | UIのEditorKitを取得します。 | 
| protected String | getKeymapName() | このUIにデフォルトでインストールまたは使用されるキーマップの名前を取得します。 | 
| Dimension | getMaximumSize(JComponent c) | エディタ・コンポーネントの最大サイズを取得します。 | 
| Dimension | getMinimumSize(JComponent c) | エディタ・コンポーネントの最小サイズを取得します。 | 
| int | getNextVisualPositionFrom(JTextComponent t, int pos, Position.Bias b, int direction, Position.Bias[] biasRet) | キャレットが配置される可能性のある、視覚的に表された次のモデル位置を決定する手段を提供します。 | 
| Dimension | getPreferredSize(JComponent c) | エディタ・コンポーネントの推奨サイズを取得します。 | 
| protected abstract String | getPropertyPrefix() | UIManagerを介してプロパティを参照するためのキーとして使用される名前を取得します。 | 
| View | getRootView(JTextComponent tc) | 関連したテキスト・コンポーネントの割り当てを持つViewを取得します。 | 
| String | getToolTipText(JTextComponent t, Point pt) | 渡された位置でツール・チップとして使用される文字列を返します。 | 
| protected Rectangle | getVisibleEditorRect() | ルートViewを渡す割り当てを取得します。 | 
| protected void | installDefaults() | フォント、フォアグラウンド、バックグラウンド、キャレットの色、選択の色、選択されたテキストの色、無効になったテキストの色、ボーダーの色などのコンポーネント・プロパティを初期化します。 | 
| protected void | installKeyboardActions() | |
| protected void | installListeners() | UIのリスナーをインストールします。 | 
| void | installUI(JComponent c) | コンポーネントのUIをインストールします。 | 
| protected void | modelChanged() | モデルの変更にフラグを立てます。 | 
| Rectangle | modelToView(JTextComponent tc, int pos) | モデル内の指定された位置を、ビュー座標体系内の場所に変換します。 | 
| Rectangle | modelToView(JTextComponent tc, int pos, Position.Bias bias) | モデル内の指定された位置を、ビュー座標体系内の場所に変換します。 | 
| void | paint(Graphics g, JComponent c) | インタフェースをペイントします。 | 
| protected void | paintBackground(Graphics g) | ビューのバックグラウンドをペイントします。 | 
| protected void | paintSafely(Graphics g) | このスレッドのビューからモデルが変更されないという保証付きで、安全にインタフェースをペイントします。 | 
| protected void | propertyChange(PropertyChangeEvent evt) | このメソッドは、関連付けられたJTextComponentでバウンド・プロパティが変更されたときに呼び出されます。 | 
| protected void | setView(View v) | ビュー階層の現在のルートを設定し、invalidate()を呼び出します。 | 
| protected void | uninstallDefaults() | nullに明示的にオーバーライドされていないコンポーネント・プロパティを設定します。 | 
| protected void | uninstallKeyboardActions() | |
| protected void | uninstallListeners() | UIのリスナーをアンインストールします。 | 
| void | uninstallUI(JComponent c) | コンポーネントのUIをアンインストールします。 | 
| void | update(Graphics g, JComponent c) | スーパー・クラスが、制御不可能な方法でバックグラウンドをペイントします。 | 
| int | viewToModel(JTextComponent tc, Point pt) | ビュー座標体系内の指定された場所を、モデル内のもっとも近い代表的な位置に変換します。 | 
| int | viewToModel(JTextComponent tc, Point pt, Position.Bias[] biasReturn) | ビュー座標体系内の指定された場所を、モデル内のもっとも近い代表的な位置に変換します。 | 
contains, createUI, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehaviorprotected Caret createCaret()
protected Highlighter createHighlighter()
protected String getKeymapName()
protected Keymap createKeymap()
 キーマップを作成するために使用されるバインディングのセットは、getPropertyPrefix()メソッドと文字列.keyBindingsを結合することでフォーマットされるキーを使用してUIManagerから取得されます。 型は、JTextComponent.KeyBinding[]になります。 
getKeymapName(), JTextComponentprotected void propertyChange(PropertyChangeEvent evt)
evt - プロパティ変更イベントprotected abstract String getPropertyPrefix()
protected void installDefaults()
protected void uninstallDefaults()
nullに明示的にオーバーライドされていないコンポーネント・プロパティを設定します。 現在の値がUIResourceでなければ、プロパティはオーバーライドされたと判断されます。 protected void installListeners()
protected void uninstallListeners()
protected void installKeyboardActions()
protected void uninstallKeyboardActions()
protected void paintBackground(Graphics g)
g - グラフィックス・コンテキストprotected final JTextComponent getComponent()
protected void modelChanged()
protected final void setView(View v)
v - ルート・ビューprotected void paintSafely(Graphics g)
g - グラフィックス・コンテキストpublic void installUI(JComponent c)
nullまたはUIResourceのインスタンスである場合にのみ設定されます。 
 installUI、クラスComponentUIc - エディタ・コンポーネントComponentUI.installUI(javax.swing.JComponent)public void uninstallUI(JComponent c)
uninstallUI、クラスComponentUIc - エディタ・コンポーネントComponentUI.uninstallUI(javax.swing.JComponent)public void update(Graphics g, JComponent c)
ノート: ノート:また、スーパー・クラスはバックグラウンドのレンダリングでスレッド・セーフではありません。ただし、このことはデフォルト・レンダリングでは問題になりません。
update、クラスComponentUIg - ペイント対象のGraphicsコンテキストc - ペイントされるコンポーネント。この引数は通常無視されるが、UIオブジェクトがステートレスで、複数のコンポーネントで共有されている場合は使用されることがあるComponentUI.paint(java.awt.Graphics, javax.swing.JComponent), JComponent.paintComponent(java.awt.Graphics)public final void paint(Graphics g, JComponent c)
paint、クラスComponentUIg - グラフィックス・コンテキストc - エディタ・コンポーネントComponentUI.update(java.awt.Graphics, javax.swing.JComponent)public Dimension getPreferredSize(JComponent c)
getPreferredSize、クラスComponentUIc - エディタ・コンポーネントJComponent.getPreferredSize(), LayoutManager.preferredLayoutSize(java.awt.Container)public Dimension getMinimumSize(JComponent c)
getMinimumSize、クラスComponentUIc - エディタ・コンポーネントJComponent.getMinimumSize(), LayoutManager.minimumLayoutSize(java.awt.Container), ComponentUI.getPreferredSize(javax.swing.JComponent)public Dimension getMaximumSize(JComponent c)
getMaximumSize、クラスComponentUIc - エディタ・コンポーネントJComponent.getMaximumSize(), LayoutManager2.maximumLayoutSize(java.awt.Container)protected Rectangle getVisibleEditorRect()
public Rectangle modelToView(JTextComponent tc, int pos) throws BadLocationException
modelToView、クラスTextUItc - このUIがインストールされているテキスト・コンポーネントpos - 変換対象のモデル内でのローカル位置>= 0BadLocationException - 指定された位置が、関連付けられたドキュメント内の有効な位置を表していない場合TextUI.modelToView(javax.swing.text.JTextComponent, int)public Rectangle modelToView(JTextComponent tc, int pos, Position.Bias bias) throws BadLocationException
modelToView、クラスTextUItc - このUIがインストールされているテキスト・コンポーネントpos - 変換対象のモデル内でのローカル位置>= 0BadLocationException - 指定された位置が、関連付けられたドキュメント内の有効な位置を表していない場合TextUI.modelToView(javax.swing.text.JTextComponent, int)public int viewToModel(JTextComponent tc, Point pt)
viewToModel、クラスTextUItc - このUIがインストールされているテキスト・コンポーネントpt - 変換対象のビューの座標系での位置。 この場合の座標系は、マウス・イベントと同じ座標系であるべきである。 TextUI.viewToModel(javax.swing.text.JTextComponent, java.awt.Point)public int viewToModel(JTextComponent tc, Point pt, Position.Bias[] biasReturn)
viewToModel、クラスTextUItc - このUIがインストールされているテキスト・コンポーネントpt - 変換対象のビューの座標系での位置。 この場合の座標系は、マウス・イベントと同じ座標系であるべきである。 biasReturn - 指定された点がモデル内の前の文字と次の文字のどちらに近いのかを示すため、このメソッドによって書き込まれるTextUI.viewToModel(javax.swing.text.JTextComponent, java.awt.Point)public int getNextVisualPositionFrom(JTextComponent t, int pos, Position.Bias b, int direction, Position.Bias[] biasRet) throws BadLocationException
getNextVisualPositionFrom、クラスTextUIt - このUIがインストールされているテキスト・コンポーネントpos - 変換対象の位置>= 0b - 位置のバイアスdirection - 現在位置からの方向。キーボードに通常見られる矢印キーと見なすことができる。 SwingConstants.WEST、SwingConstants.EAST、SwingConstants.NORTHまたはSwingConstants.SOUTHの場合があります biasRet - 返される位置のバイアスを含む配列BadLocationExceptionpublic void damageRange(JTextComponent tc, int p0, int p1)
damageRange、クラスTextUItc - このUIがインストールされているテキスト・コンポーネントp0 - 範囲の始点>= 0p1 - 範囲の終点>= p0TextUI.damageRange(javax.swing.text.JTextComponent, int, int)public void damageRange(JTextComponent t, int p0, int p1, Position.Bias p0Bias, Position.Bias p1Bias)
damageRange、クラスTextUIp0 - 範囲の始点>= 0p1 - 範囲の終点>= p0public EditorKit getEditorKit(JTextComponent tc)
getEditorKit、クラスTextUItc - このUIがインストールされているテキスト・コンポーネントTextUI.getEditorKit(javax.swing.text.JTextComponent)public View getRootView(JTextComponent tc)
ノート: View階層はルート・ビューからトラバースすることができ、ほかのことも同様にできます。 このように行われたことは、TextUIを通じた単純なメソッド呼出しのように保護することができません。 したがって、並行処理が存在する場合には、このメソッドを呼び出すロジックによって、適切な処理を準備する必要があります。
getRootView、クラスTextUItc - このUIがインストールされているテキスト・コンポーネントTextUI.getRootView(javax.swing.text.JTextComponent)public String getToolTipText(JTextComponent t, Point pt)
getToolTipText、クラスTextUIJTextComponent.getToolTipText(java.awt.event.MouseEvent), View.getToolTipText(float, float, java.awt.Shape)public View create(Element elem)
create、インタフェースViewFactoryelem - 要素View バグまたは機能を送信 
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。 そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。 
 Copyright © 1993, 2025, Oracle and/or its affiliates.  All rights reserved.  Use is subject to license terms.  Documentation Redistribution Policyも参照してください。