在同一个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中选择文本!
发布于 2014-04-08 17:11:15
jeditorpane1.selectAll();
jeditorpane2.selectAll();但是当JEditorPane没有被聚焦时,选择是不可见的
要使其可见,请使用
((DefaultCaret)jeditorpane1.getCaret()).setSelectionVisible(true);https://stackoverflow.com/questions/22931926
复制相似问题