Im trying to under stand this program I found

Im trying to under stand this program I found. Where should the methods go within this prog. But I'm unable to fix the method problem.

Error messages

GraphicUserInterface.java:47: cannot find symbol

symbol : method getPath()

location: class java.io.File[]

System.out.println("GUI deleteFiles - file #" + i + " to delete = " + bob.getPath());

^

GraphicUserInterface.java:48: cannot find symbol

symbol : method Delete()

location: class java.io.File[]

bob.Delete();

2 errors ^

[CODE]

import java.io.File

import javax.swing.filechooser.*;

import java.io.*;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class GraphicUserInterface

{

JFrame commandFrame;

JPanel commandPanel;

JFileChooser thePlanetsBrowser;

JButton deleteSelectedFilesButton;

File DirBit = new File("C:\\Documents and Settings\\Loop\\Desktop\\theGrey");

public GraphicUserInterface()

{

JFrame.setDefaultLookAndFeelDecorated(true);

commandFrame = new JFrame("At your command");

commandFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

commandPanel = new JPanel(new GridBagLayout());

thePlanetsBrowser = new JFileChooser(DirBit);

thePlanetsBrowser.setMultiSelectionEnabled(true);

commandPanel.add(thePlanetsBrowser);

deleteSelectedFilesButton = new JButton("Delete selected files");

deleteSelectedFilesButton.addActionListener(new java.awt.event.ActionListener()

{

public void actionPerformed(ActionEvent e)

{

deleteSelectedFilesButtonActionPerformed();

System.out.println("GUI deleteSelectedFilesButton Listener - deletion finished");

}

});

commandPanel.add(deleteSelectedFilesButton);

commandFrame.getContentPane().add(commandPanel, BorderLayout.CENTER);

commandFrame.pack();

commandFrame.setVisible(true);

}

public void deleteSelectedFilesButtonActionPerformed()

{

File[] bob = thePlanetsBrowser.getSelectedFiles();

System.out.println("GUI deleteSelectedFilesButton - # of files to delete = " + bob.length);

if (thePlanetsBrowser.getCurrentDirectory().equals(DirBit))

{

System.out.println("GUI deleteFiles - directory is OK");

for (int i = 0; i < bob.length; i++)

{

System.out.println("GUI deleteFiles - file #" + i + " to delete = " + bob.getPath());

bob.delete();

System.out.println("GUI deleteFiles - deleted");

}

}

try

{

thePlanetsBrowser.rescanCurrentDirectory();

System.out.println("GUI deleteFiles - rescan done");

}

catch (java.lang.ArrayIndexOutOfBoundsException e)

{

System.out.println("HERE IS THE ArrayIndexOutOfBoundsException: " + e);

}

}

private static void createAndShowGUI()

{

new GraphicUserInterface();

}

public static void main(String[] args)

{

javax.swing.SwingUtilities.invokeLater(new Runnable()

{

public void run()

{

createAndShowGUI();

}

});

}

}[/CODE]

[3219 byte] By [aceofbasea] at [2007-10-2 2:07:21]
# 1

Sorry about that, here's the code again.

import java.io.File

import javax.swing.filechooser.*;

import java.io.*;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class GraphicUserInterface

{

JFrame commandFrame;

JPanel commandPanel;

JFileChooser thePlanetsBrowser;

JButton deleteSelectedFilesButton;

File DirBit = new File("C:\\Documents and Settings\\Loop\\Desktop\\theGrey");

public GraphicUserInterface()

{

JFrame.setDefaultLookAndFeelDecorated(true);

commandFrame = new JFrame("At your command");

commandFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

commandPanel = new JPanel(new GridBagLayout());

thePlanetsBrowser = new JFileChooser(DirBit);

thePlanetsBrowser.setMultiSelectionEnabled(true);

commandPanel.add(thePlanetsBrowser);

deleteSelectedFilesButton = new JButton("Delete selected files");

deleteSelectedFilesButton.addActionListener(new java.awt.event.ActionListener()

{

public void actionPerformed(ActionEvent e)

{

deleteSelectedFilesButtonActionPerformed();

System.out.println("GUI deleteSelectedFilesButton Listener - deletion finished");

}

});

commandPanel.add(deleteSelectedFilesButton);

commandFrame.getContentPane().add(commandPanel, BorderLayout.CENTER);

commandFrame.pack();

commandFrame.setVisible(true);

}

public void deleteSelectedFilesButtonActionPerformed()

{

File[] bob = thePlanetsBrowser.getSelectedFiles();

System.out.println("GUI deleteSelectedFilesButton - # of files to delete = " + bob.length);

if (thePlanetsBrowser.getCurrentDirectory().equals(DirBit))

{

System.out.println("GUI deleteFiles - directory is OK");

for (int i = 0; i < bob.length; i++)

{

System.out.println("GUI deleteFiles - file #" + i + " to delete = " + bob.getPath());

bob.delete();

System.out.println("GUI deleteFiles - deleted");

}

}

try

{

thePlanetsBrowser.rescanCurrentDirectory();

System.out.println("GUI deleteFiles - rescan done");

}

catch (java.lang.ArrayIndexOutOfBoundsException e)

{

System.out.println("HERE IS THE ArrayIndexOutOfBoundsException: " + e);

}

}

private static void createAndShowGUI()

{

new GraphicUserInterface();

}

public static void main(String[] args)

{

javax.swing.SwingUtilities.invokeLater(new Runnable()

{

public void run()

{

createAndShowGUI();

}

});

}

}

aceofbasea at 2007-7-15 19:48:47 > top of Java-index,Java Essentials,New To Java...
# 2
Let me guess: You've got that code from somewhere in this forum.Because you're missing "[i]" in some places and that's because the forum software interprets it as a way to make your text coursive, unless you enclose it in code-tags.
JoachimSauera at 2007-7-15 19:48:47 > top of Java-index,Java Essentials,New To Java...