当前位置: 首页>>代码示例>>Java>>正文


Java TextHitInfo.leading方法代码示例

本文整理汇总了Java中java.awt.font.TextHitInfo.leading方法的典型用法代码示例。如果您正苦于以下问题:Java TextHitInfo.leading方法的具体用法?Java TextHitInfo.leading怎么用?Java TextHitInfo.leading使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.font.TextHitInfo的用法示例。


在下文中一共展示了TextHitInfo.leading方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLocationOffset

import java.awt.font.TextHitInfo; //导入方法依赖的package包/类
public TextHitInfo getLocationOffset(int x, int y) {
    if (composedTextAttribute == null) {
        return null;
    } else {
        Point p = getLocationOnScreen();
        p.x = x - p.x;
        p.y = y - p.y;
        int pos = viewToModel(p);
        if ((pos >= composedTextStart.getOffset()) &&
            (pos <= composedTextEnd.getOffset())) {
            return TextHitInfo.leading(pos - composedTextStart.getOffset());
        } else {
            return null;
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:JTextComponent.java

示例2: x2Index

import java.awt.font.TextHitInfo; //导入方法依赖的package包/类
static TextHitInfo x2Index(TextLayout textLayout, float x) {
    TextHitInfo hit;
    hit = textLayout.hitTestChar(x, 0);
    // Use forward bias only since BaseCaret and other code is not sensitive to backward bias yet
    if (!hit.isLeadingEdge()) {
        hit = TextHitInfo.leading(hit.getInsertionIndex());
    }
    return hit;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:HighlightsViewUtils.java

示例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();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:49,代码来源:bug8041990.java


注:本文中的java.awt.font.TextHitInfo.leading方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。