Hello
I would like to ask how to change button "Open" to "save" when iam using JFileChooser

public void actionPerformed(ActionEvent e) 
    {

        Object zrodlo =e.getSource();

        if(zrodlo == mSave)//zapisywanie pliku 
        {
            JFileChooser fc = new JFileChooser();
            fc.setSelectedFile(new File(fileName));
            fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
            FileNameExtensionFilter filter = new FileNameExtensionFilter(
                        ".txt and .java files", "txt");
                fc.setFileFilter(filter);
            if (fc.showOpenDialog(null)==JFileChooser.APPROVE_OPTION)
            {
                File plik = fc.getSelectedFile();
                fileName = plik.getName();
                try 
                {
                    PrintWriter pw = new PrintWriter(plik);
                    Scanner skaner = new Scanner(resultTA.getText());
                    while (skaner.hasNext())
                        pw.println(skaner.nextLine() + "\n");
                    pw.close();
                } 

                catch (FileNotFoundException e1)
                {

                    e1.printStackTrace();
                }

            }
        }



        }

Replace fc.showOpenDialog with fc.showSaveDialog.

commented: good suggestion +4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.