在同一个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中选择文字!
答案 0 :(得分:1)
jeditorpane1.selectAll();
jeditorpane2.selectAll();
但是当JEditorPane
没有聚焦时,选择是不可见的
使其可见使用
((DefaultCaret)jeditorpane1.getCaret()).setSelectionVisible(true);