Computer Science Canada Cleaner Program Help |
Author: | Krocker [ Sat Dec 31, 2011 12:35 pm ] | ||||
Post subject: | Cleaner Program Help | ||||
hey guys, ok so im creating a program which delete specific folder and whats in them. The problem im having is that i have 2 classes ~ one has my guis and buttons, the other has the deleting process. What i dont know is how to make it so that when the clean button is pressed, it class the delete method from the other class. Heres my codes Main Process (Guis/Main Interface)
dProcess (Deleting Class)
|
Author: | ProgrammingFun [ Sat Dec 31, 2011 12:47 pm ] |
Post subject: | RE:Cleaner Program Help |
If both classes are in the same folder, they can communicate with each other just as they would if they were in the same program. Another way to connect them can be extends |
Author: | Krocker [ Sat Dec 31, 2011 3:03 pm ] |
Post subject: | RE:Cleaner Program Help |
ok, but thats the thing, i dont know to to communicate with each other. Please explain and give me an example to follow. THX ALOT |
Author: | ProgrammingFun [ Sat Dec 31, 2011 4:32 pm ] | ||||
Post subject: | RE:Cleaner Program Help | ||||
First off, you need to make sure that one of you classes is finished in all of its coding. This is normally the class that does not contain the main program, for you, you would have to comple dProcess first. Next, place the .class that is generated into the same folder as your other java file if it is not already there. After this point, you can call any method in the compiled class as you would call it normally. This is done as follows: dProcess file
My Main Program Class
Hope this helps, it is explained in more detail here: http://www.roseindia.net/java/javascript-array/call-method-another-class.shtml If you still do not understand it, I would suggest just sticking with one class for now. |
Author: | Krocker [ Sat Dec 31, 2011 7:20 pm ] |
Post subject: | RE:Cleaner Program Help |
ok so i followed what u said and im getting an error saying that : No application overload for the method named "main" was found in type "kcleaner.dProcess". Perhaps you wanted overload version "void main (java.lang.String[] argv) throws java.lang.Exception;" instead? I have no idea what that means, so heres the code for that error. Note that the method is called when a button is pressed in the main program. public void actionPerformed (ActionEvent e) { dProcess method = new dProcess (); if (e.getSource () == b1) { JOptionPane.showMessageDialog (null, "KCleaner is Done!"); method.main (); } else if (e.getSource () == b2) { JOptionPane.showMessageDialog (null, "Thank You For Using KCleaner"); f1.setVisible (false); } } public static void main (String args[]) { new Test (); } } |
Author: | ProgrammingFun [ Sat Dec 31, 2011 7:48 pm ] | ||
Post subject: | Re: RE:Cleaner Program Help | ||
Krocker @ Sat Dec 31, 2011 7:20 pm wrote: public static void main (String args[]) This should be:
EDIT: Also, why do you have a main method in each class? You only need one of those, the main method is supposed to be the one that initializes everything. |
Author: | Krocker [ Sun Jan 01, 2012 10:23 am ] |
Post subject: | RE:Cleaner Program Help |
ok, but the error is coming from the "method.main ();" |
Author: | ProgrammingFun [ Sun Jan 01, 2012 12:12 pm ] |
Post subject: | Re: RE:Cleaner Program Help |
Krocker @ Sun Jan 01, 2012 10:23 am wrote: ok, but the error is coming from the "method.main ();"
What does your "main" look like in you "method" class? |
Author: | Krocker [ Sun Jan 01, 2012 1:10 pm ] | ||
Post subject: | Re: RE:Cleaner Program Help | ||
ProgrammingFun @ Sun Jan 01, 2012 12:12 pm wrote: Krocker @ Sun Jan 01, 2012 10:23 am wrote: ok, but the error is coming from the "method.main ();"
What does your "main" look like in you "method" class? Main Method:
|
Author: | ProgrammingFun [ Sun Jan 01, 2012 1:28 pm ] |
Post subject: | RE:Cleaner Program Help |
http://en.wikipedia.org/wiki/Main_function#Java |
Author: | Krocker [ Sun Jan 01, 2012 5:50 pm ] |
Post subject: | RE:Cleaner Program Help |
... nice tutorial, but that doesnt help me in my case |