在同一个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);