本文整理汇总了Java中java.awt.font.TextHitInfo.trailing方法的典型用法代码示例。如果您正苦于以下问题:Java TextHitInfo.trailing方法的具体用法?Java TextHitInfo.trailing怎么用?Java TextHitInfo.trailing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.font.TextHitInfo
的用法示例。
在下文中一共展示了TextHitInfo.trailing方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: x2RelOffset
import java.awt.font.TextHitInfo; //导入方法依赖的package包/类
static TextHitInfo x2RelOffset(TextLayout textLayout, float x) {
TextHitInfo hit;
x -= EXTRA_MARGIN_WIDTH;
if (x >= textLayout.getAdvance()) {
hit = TextHitInfo.trailing(textLayout.getCharacterCount());
} else {
hit = textLayout.hitTestChar(x, 0); // What about backward bias -> with higher offsets it may go back visually
}
return hit;
}
示例2: init
import java.awt.font.TextHitInfo; //导入方法依赖的package包/类
public void init(TestEnvironment env, Result results) {
super.init(env, results);
ArrayList list = new ArrayList(text.length() * 2 + 2);
TextHitInfo hit = TextHitInfo.trailing(-1);
do {
list.add(hit);
hit = tl.getNextRightHit(hit);
} while (hit != null);
hits = (TextHitInfo[])list.toArray(new TextHitInfo[list.size()]);
lb = tl.getBounds();
lb.setRect(lb.getMinX() - 10, lb.getMinY(), lb.getWidth() + 20, lb.getHeight());
}
示例3: main
import java.awt.font.TextHitInfo; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
ThreadGroup stubTG = new ThreadGroup(getRootThreadGroup(), "Stub Thread Group");
ThreadGroup swingTG = new ThreadGroup(getRootThreadGroup(), "SwingTG");
try {
Thread stubThread = new Thread(stubTG, SunToolkit::createNewAppContext);
stubThread.start();
stubThread.join();
CountDownLatch startSwingLatch = new CountDownLatch(1);
new Thread(swingTG, () -> {
SunToolkit.createNewAppContext();
SwingUtilities.invokeLater(() -> {
frame = new JFrame();
component = new JLabel("Test Text");
frame.add(component);
frame.setBounds(100, 100, 100, 100);
frame.setVisible(true);
startSwingLatch.countDown();
});
}).start();
startSwingLatch.await();
AtomicReference<Exception> caughtException = new AtomicReference<>();
Thread checkThread = new Thread(getRootThreadGroup(), () -> {
try {
// If the bug is present this will throw exception
new InputMethodEvent(component,
InputMethodEvent.CARET_POSITION_CHANGED,
TextHitInfo.leading(0),
TextHitInfo.trailing(0));
} catch (Exception e) {
caughtException.set(e);
}
});
checkThread.start();
checkThread.join();
if (caughtException.get() != null) {
throw new RuntimeException("Failed. Caught exception!", caughtException.get());
}
} finally {
new Thread(swingTG, () -> SwingUtilities.invokeLater(() -> {
if (frame != null) {
frame.dispose();
}
})).start();
}
}