简体   繁体   中英

Select Text From multiple JEditorPane

In the same JPanel , i have two JEditorPane , how i can select text from the two JEditorPane at the same time

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);

I use mouse to select text from jeditorpane !

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

But when JEditorPane is not focused selection is invisible

to make it visible use

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM