-
Is this a freakin joke?!
I decided to try my hand at java.....so far i'm not impressed....i just spent the last hour trying to figure out why my button wasn't showing up in the window.. everything compiled fine, without any warning....still, no button.........
i fixed it, but appearantly, the (sole) constructor which created the button, wasn't getting called.....
i had...
Code:
public class MyClass{
public void MyClass(){...}
}
what's wrong with this picture?
should i expect a lot more of this out of java?
-
You sure you created an instance of the class somewhere? Note that everything (most) is pointers in java so you have to use the new operator, not just this: MyClass c;
-
no no...i figured out the problem before i posted here...
i posted because i was a bit disgusted that the java compiler let me compile a constructor with a return type and didn't say a word. because it had a return type, the overload didn't get resolved "properly"
-
from your post it is really not clear what is wrong, and how java is at fault here. Most likely it is your inexperiance with the language that caused the problem and not the language it self.
What IDE are you using? and then, are you using awt or swing libraries?
-
ide = commando
i'm using swing, which means i'm also using awt.
can a constructor return a value in java? if so, why does Learning Java by O'Reilly say otherwise?
-
>> a constructor with a return type
I noticed this as soon as I saw it but I have never tried to compile it like that and I don't know if it is technically legal Java code or not. Obviously it is but I'm sure there is a reason for it. Something like that wouldn't go unnoticed easily. Maybe check to see if compiler warnings are turned on?
-
i've never even heard of that ide dude; I suggest one of these three: Eclipse, NetBeans, JbuilderX
NetBeans has a great GUI builder feature.
-
-
oh, woops :o in that case, make sure you are using the newest version of java.