Methods Summary |
---|
public void | buildUI(java.awt.Container container, java.text.AttributedCharacterIterator text)
// Create a new TextLayout from the given text.
textLayout = new TextLayout(text, DEFAULT_FRC);
// Initilize insertionIndex.
insertionIndex = 0;
hitPane = new HitPane();
container.add(hitPane, BorderLayout.CENTER);
hitPane.addMouseListener(new HitTestMouseListener());
|
private java.awt.geom.Point2D | computeLayoutOrigin()Compute a location within this Component for textLayout's origin,
such that textLayout is centered horizontally and vertically.
Note that this location is unknown to textLayout; it is used only
by this Component for positioning.
Dimension size = getPreferredSize();
Point2D.Float origin = new Point2D.Float();
origin.x = (float) (size.width - textLayout.getAdvance()) / 2;
origin.y = (float) (size.height - textLayout.getDescent() + textLayout.getAscent()) / 2;
return origin;
|
public java.awt.Dimension | getPreferredSize()
return preferredSize;
|
public void | init()
AttributedCharacterIterator text = helloWorld.getIterator();
buildUI(getContentPane(), text);
|
public static void | main(java.lang.String[] args)
JFrame sampleFrame = new JFrame("HitTestSample");
AttributedCharacterIterator text = helloWorld.getIterator();
final HitTestSample controller = new HitTestSample();
controller.buildUI(sampleFrame.getContentPane(), text);
sampleFrame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
sampleFrame.setSize(new Dimension(400, 250));
sampleFrame.setVisible(true);
|