1 package javax
.swing
.plaf
.basic
;
3 import javax
.swing
.text
.*;
4 import javax
.swing
.plaf
.*;
8 public class BasicTextUI
extends TextUI
11 View view
= new RootView();
12 Color textColor
, disabledTextColor
, normalBackgroundColor
;
13 EditorKit kit
= new DefaultEditorKit();
15 class RootView
extends View
21 public void paint(Graphics g
, Shape s
)
25 Rectangle r
= s
.getBounds();
27 view
.setSize((int)r
.getWidth(),
38 public static ComponentUI
createUI(final JComponent c
)
40 return new BasicTextUI();
44 public void installUI(final JComponent c
)
48 textColor
= new Color(0,0,0);
49 disabledTextColor
= new Color(130, 130, 130);
50 normalBackgroundColor
= new Color(192,192,192);
53 public Dimension
getPreferredSize(JComponent c
)
55 JTextComponent b
= (JTextComponent
) c
;
57 View v
= getRootView(b
);
59 float w
= v
.getPreferredSpan(View
.X_AXIS
);
60 float h
= v
.getPreferredSpan(View
.Y_AXIS
);
62 return new Dimension((int)w
, (int) h
);
66 public void paint(Graphics g
, JComponent c
)
71 public void damageRange(JTextComponent t
, int p0
, int p1
)
73 damageRange(t
, p0
, p1
, null, null);
76 public void damageRange(JTextComponent t
,
78 Position
.Bias firstBias
,
79 Position
.Bias secondBias
)
83 public EditorKit
getEditorKit(JTextComponent t
)
88 public int getNextVisualPositionFrom(JTextComponent t
,
92 Position
.Bias
[] biasRet
)
97 public View
getRootView(JTextComponent t
)
102 public Rectangle
modelToView(JTextComponent t
, int pos
)
104 return modelToView(t
, pos
, null);
107 public Rectangle
modelToView(JTextComponent t
, int pos
, Position
.Bias bias
)
112 public int viewToModel(JTextComponent t
, Point pt
)
114 return viewToModel(t
, pt
, null);
117 public int viewToModel(JTextComponent t
, Point pt
, Position
.Bias
[] biasReturn
)