Q:

Edit the text selected in JtextPane

I have two Jtextpane what i want to do is that i what to select the text from 1 Jtextpane and i want that it should appear in the second Jtextpane after a menu item Edit is selected
which i have done
 popMenu[i].addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        String str = e.getActionCommand();
                   .....
                        if (str.equalsIgnoreCase("edit")) {
                            taSecond.setBackground(new Color(0xFBFCDD));
                            taSecond.setText(taFirst.getSelectedText());
                            System.out.println("bounds====>"+taFirst.getBounds());
                            taFirst.getBounds().setBounds(taFirst.getBounds());
                            editedText = true;

                        }
                    }
                });

Now I am clueless that how would i put the edited  text back to the selcted position from where i got the text
can anyone tell the solution

A:

Thank you
try {

                    doc.remove(start, end-start);
                    doc.insertString(start, str, normal);
                    editedText=false;
                } catch (BadLocationException ex) {
                    Logger.getLogger(ChatPane.class.getName()).log(Level.SEVERE, null, ex);
                }

