-3

I am developing a GUI in Java using the Netbeans IDE and swing forms. Here I want to delete the selected text from the Jscrollpane using a DELETE button which I have added by using an ADD button. I am able to delete the entire text but not the selected one. I have searched on Internet but could not get any help. Below is the code which I have tried. Any suggestions will be helpful for me.

private void buttondelActionPerformed(java.awt.event.ActionEvent evt) {                                          
    JFileChooser chooser = new JFileChooser();
    FileFilter ft = new FileNameExtensionFilter( "arxml Files", "arxml" );
    chooser.setFileFilter(ft);
    jScrollPane1.getContainerListeners(); 
    chooser.setMultiSelectionEnabled(true);
    JOptionPane.showConfirmDialog(frame, "You Selected : " + list.getSelectedValue());
    if (evt.getSource() == buttondel )
    {
         File[] files = chooser.getSelectedFiles();
        log.setText("");
    }
STaefi
  • 4,297
  • 1
  • 25
  • 43
Priyanka
  • 97
  • 1
  • 2
  • 9
  • 1
    http://stackoverflow.com/questions/12492817/how-to-get-selection-from-jtextpane#12496636 and http://stackoverflow.com/questions/15859289/how-to-make-selected-text-in-jtextarea-into-a-string is your answer – GOXR3PLUS May 09 '16 at 09:31

1 Answers1

0

Your JScrollPane must have a JTextArea where you will be putting the content. Add a listener to the JTextArea and get the selected text on an action performed. Then delete the selected text

Draken
  • 3,134
  • 13
  • 34
  • 54