gpt4 book ai didi

java - 从多个 JEditorPane 选择文本

转载 作者:行者123 更新时间:2023-12-01 13:10:15 25 4
gpt4 key购买 nike

在同一个JPanel中,我有两个JEditorPane,如何同时从两个JEditorPane中选择文本

>
JPanel panel=new JPanel(new BorderLayout());
JEditorPane jeditorpane1=new JEditorPane();
// Set content of jeditorpane1
JEditorPane jeditorpane2=new JEditorPane();
// Set content of jeditorpane2
panel.add(jeditorpane1,BorderLayout.WEST);
panel.add(jeditorpane2,BorderLayout.EAST);

我使用鼠标从 jeditorpane 中选择文本!

最佳答案

jeditorpane1.selectAll();
jeditorpane2.selectAll();

但是当JEditorPane未获得焦点时,选择是不可见的

使其可见使用

((DefaultCaret)jeditorpane1.getCaret()).setSelectionVisible(true);

关于java - 从多个 JEditorPane 选择文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22931926/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com