
-----------------------------------
gsquare567
Tue Oct 31, 2006 9:07 pm

Need help debugging my EasyPlannerApp
-----------------------------------
okay, so the thing works, all except for the edit command. it either a) doesnt edit the contact, or b) duplicates the list + (a). i've looked through it, and i'm a beginner with the whole swing thing so if its something small then dont make fun :D. thanks a LOT for any1 who helps, or just reads my entire code. it has tons of commenting so you can understand it even if you dont know java lol. thanks, and heres the code:

-----------------------------------
rdrake
Tue Oct 31, 2006 9:33 pm


-----------------------------------
Please, please, please PLEASE attach the source file in the post when it's ~100 lines or above.

-----------------------------------
Andy
Tue Oct 31, 2006 9:38 pm


-----------------------------------
bam! i'm on a roll today  :D

-----------------------------------
gsquare567
Wed Nov 01, 2006 12:41 pm


-----------------------------------
so is any1 gonna read it???

-----------------------------------
gsquare567
Fri Nov 03, 2006 10:28 pm


-----------------------------------
comon

-----------------------------------
Booya
Wed Nov 08, 2006 2:55 pm

Code
-----------------------------------
i was looking through the code had like a ton of errors in it and it was too long sorry but i dont have the time to fully look at it on the weekend ill attepmt to see whats wrong with it.

-----------------------------------
batman
Wed Nov 08, 2006 2:58 pm

Program
-----------------------------------
Wow this is a very long code!!!!!!!! Ok i dont know if ur teacher talked to you about this but using classes then using interference to make other classes then using a applet afterwards. Basically this makes smaller pieces of ur code. Maybe I should do a tutorial on how to do this using interference????????? Or maybe someones already done that.

-----------------------------------
wtd
Wed Nov 08, 2006 3:29 pm


-----------------------------------
Interference?

Perhaps you mean inheritance.  That concept is covered quite well in the [url=http://compsci.ca/v2/viewtopic.php?t=9576]Introduction to Java.

-----------------------------------
batman
Wed Nov 08, 2006 4:29 pm

Code
-----------------------------------

Interference? 

Perhaps you mean inheritance. That concept is covered quite well in the Introduction to Java.


Inheritance is what I mean my bad. Yea so gsquare567 if i were u u should go to the introduction to java and try to learn how to use inheritance. It will make ur code much neater. Also you need to add more comments so we can undertsand what u are doing.

-----------------------------------
gsquare567
Thu Nov 09, 2006 6:27 pm


-----------------------------------
thanks for actually reading my code!
btw, i have no teacher, i self-taught myself, and also, i know what inheritance is but what are you talking about? how can i use inheritance (extends or implements, right?) here? i was thinking of making another class in the same file called Contact but its already done and i'll do that later once i figure out this problem. but do you know why it isnt editing properly?

-----------------------------------
gsquare567
Wed Nov 15, 2006 2:12 pm


-----------------------------------
waiting

-----------------------------------
wtd
Wed Nov 15, 2006 5:35 pm


-----------------------------------
A piece of feedback...

You have:

   private void centerWindow(Window w)

   {

      Toolkit tk = Toolkit.getDefaultToolkit();// creates a Toolkit object

      Dimension d = tk.getScreenSize();// creates a Dimension object using the Toolkit object



      setLocation((d.width-w.getWidth())/2, (d.height-w.getHeight())/2);

      // sets the frames location to the width/2 and the height/2

   }

Now, there are afew issues here.  First, the syntactic stuff.  The superficial (but important) things.

Your first two comments are utterly unnecessary.  If the person cannot figure this information out from the code, then they don't know Java and shouldn't be reading your code.  Your third comment, meanwhile, should be on the line preceding the code it is concerned with.

However, there is a much bigger, fundamental, "OOP is weird" issue going on here.

You have your instance method take a parameter that is a Window object.  But... when you use this, you just pass in "this".  This is redundant.

   private void centerWindow() {
      Toolkit tk = Toolkit.getDefaultToolkit();
      Dimension d = tk.getScreenSize();

      // sets the frames location to the width/2 and the height/2
      setLocation((d.width - this.getWidth()) / 2, (d.height - this.getHeight()) / 2);
   }

One last thing.

[code]   private void centerWindow() {
      Dimension d = Toolkit.getDefaultToolkit().getScreenSize();

      // sets the frames location to the width/2 and the height/2
      setLocation((d.width - this.getWidth()) / 2, (d.height - this.getHeight()) / 2);
   }[/code]

-----------------------------------
gsquare567
Fri Nov 17, 2006 7:56 pm


-----------------------------------
haha thanks i guess... i use it as more of a universal method i just copy and paste, no use making a diff class just for that, but the window could be many things, and my comments are extremely basic throughout... but i just made that when i was just starting and havent really thought about just taking out those 2. can you please read my code you could probably solve my problem in a second.

-----------------------------------
wtd
Fri Nov 17, 2006 8:27 pm


-----------------------------------
I could probably find the root of your problem readily, were your code not so infernally hard to read do to the little details you probably don't think I should waste time pointing out.  :)

Your comments, for instance, are horrible.  Comments should be used sparingly, and not to say things the code itself is saying.  When they are used, they should precede the code to which they apply.

-----------------------------------
gsquare567
Sun Nov 19, 2006 7:21 pm


-----------------------------------
ok dude, firstly, calm down... im used to putting so many comments for skewl java course. it doesnt make it THAT much harder to read... you probably couldnt help me anyways its probably too advanced. if any1 knows java.io pack well then try skimming through my edit function :D

-----------------------------------
ericfourfour
Sun Nov 19, 2006 7:32 pm


-----------------------------------
you probably couldnt help me anyways
Yeah, that is so true. wtd is not known for his programming ability :wink:

Talking like that will never get you any help especially when you make fun of the only people who can help you. You are likely going to just get ignored.

-----------------------------------
wtd
Sun Nov 19, 2006 8:11 pm


-----------------------------------
ok dude, firstly, calm down... im used to putting so many comments for skewl java course. it doesnt make it THAT much harder to read... you probably couldnt help me anyways its probably too advanced. if any1 knows java.io pack well then try skimming through my edit function :D

It does make it that much harder to read, and I do not wih to spend hours of my time simply rewriting your code before I even begin looking for the problem.

As for your event handling, your code would be much easier to debug also if instead of a single implementation of ActionListener and a conditional with, you used anonymous inner classes to add an ActionListener to each applicable component.

-----------------------------------
gsquare567
Tue Nov 21, 2006 6:47 pm


-----------------------------------
Talking like that will never get you any help especially when you make fun of the only people who can help you.

a) im not making fun
b) anyone on this site and many other CAN help me, just theyre not fast enough and dont want to waste their time...

as for you, wtd, after the editing problem is solved, you can tell me all you want about how crappy my code is and how to do it like a pro as you, but atm this editing thing is really frustrating because it should work... its combining the deleting and adding functions which worked perfectly. its really not that long a read, just start in the event of the accept button pressed and the editButtonPressed boolean is true, and then the addContactToFile and removeContactFromFile methods.

-----------------------------------
wtd
Tue Nov 21, 2006 10:14 pm


-----------------------------------
See... well-formatted code is not something you do after the fact.  It's something you do as you go, so that it's much much easier to find problems and fix them.

If I can't read your code, then I can't help you fix it, and I doubt you are immune to the same problem.
