Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

Ben Hultin

Ranch Hand
+ Follow
since Aug 17, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ben Hultin

so would that be something like this?

10 years ago
I am working on an assignment to create an applet where I need to change the background color of the applet with some button clicks


I am not getting any errors in eclipse so far, here is my code:



I appreciate the help
10 years ago
That is it, I dont have any errors all I have is a warning (the one mentioned above). Like I said this exact file, by itself worked fine in eclipse before. Plus I have checked it on a web hoster and it also works there as well. So I assuming that this is an eclipse issue.
Ok then I will just ignore it.

My other and bigger problem is that when I compile an run the applet, I get a meesage on the applet saying:


Applet not initialized



Now this code has worked perfectly fin in the past, on a website and on eclipse. When I deleted and rebuilt the project on eclipse, I now get this.

I have a basic setup, just the defaults. I have the source code placed under the '(default package)' thats inside the 'src' folder.

Thats it, that is all I have done to the default project set up.

Any ideas?

Thanks a lot
Sorry about that, very true. Guess my mind was just wrapped up on GUI's that I put it there w/out thinking.

Well I looked into my set up and eclipse is already set for it to be a warning. Any ideas?
I am getting an error in eclipse about my applet class saying:


Description Resource Path Location Type
The serializable class Applet_Form does not declare a static final serialVersionUID field of type long Applet_Form.java /Applet/src line 4 Java Problem




I have used this exact code in the past just fine. and when compiling this time I get a response of applet not initialized.

Here is my code:



I appreciate any help in this matter
At first I wasnt sure what you were meaning, I had one funky idea, but figured that must not be it. So I tried another way that made a lot more sense the more I thought about it.

myPanel can be used to set the background color and call setD() bc Oval_Sub_1 has the super class JPanel. No need to create another one. Once that clicked, then I knew what you were saying and what I needed to do to finish the program.

Works great, thanks a lot for the help
10 years ago
well these are the two lines I used to properly reference it, so I would imagine on the original instance, seeing as there wasnt one before.



This is all found in Oval_Sub.java

Originally I had it set up as so:



But this wouldnt make much sense seeing as myPanel refers to a JPanel (or would it?) plus the compiler has no idea where setD() is located, so thats why I made the object to make a reference.
10 years ago
Thanks a lot for the help, That fixed it. I compiled it without any errors but now I belive I may have shot myself in the foot.

I have another driven class that uses JPanel as the superclass:



Mainly this was holding setD() which is called into use in Oval_Sub class. So I decided I should make an object of this class to gain acess to setD().

While the program loaded no prb, the Oval would not appear, only the JPanel and slider works so far. Any thoughts on how I could rectify this?

Thanks
10 years ago
Thanks a lot for the help, I guess I am rustier than I thought with java.

Do you have any idea about the ChangeListener not being abstract and needing? to be in order to work with SateChanged()

I appreciate the help
10 years ago
well now that I look at it. It does seem that drawOval wouldnt be a class but merely a method from the graphics library.
And the way in which myPanel is used it would suggest that it is a JPanel as you said. So to make this work better I made these adjustments:



I have two problems left in my code:




C:\Documents and Settings\ben\Desktop\park>javac Oval.java
.\Oval_Sub.java:14: call to super must be first statement in constructor
super("the title");
^
.\Oval_Sub.java:28: <anonymous Oval_Sub$1> is not abstract and does not override
abstract method stateChanged(javax.swing.event.ChangeEvent) in javax.swing.even
t.ChangeListener
new ChangeListener() {
^
2 errors



I am clueless about the first one. It must be something else
10 years ago
I am trying out this tutorial to get this drawOval() to work but the compiler tells me that the drawOval cant be found.

I triple checked that my initialization is in place, and I have imported the proper library to get it to work. So I am at a loss here.

my code:



I appreciate the help
10 years ago
Thanks a lot for the help, I took a look around read a quick tutorial on checking methods to be null or not. I tried two different methods, but I wasnt able to get a reponse either way about if they are null or not. Here are the two methods I checked.





I put both of these tests at the bottom of the constructor. Suggestions on how I can check if they null or not?
10 years ago
Sorry about that, I deleted all my comments I added to help remember what everything does. Here is as it was before I deleted the comments



# Exception in thread "main" java.lang.NullPointerException
# at Screen_Sub.restoreScreen(Screen_Sub.java:54)
# at Screen_Main.run(Screen_Main.java:44)
# at Screen_Main.main(Screen_Main.java:15)





Screen_Main.java



Screen_Sub.java

10 years ago
I am trying to get a fullScreen window created. After going through a few tutorials on it I narrowed my problem down to this error:




here is my driver file:


here is my driven file:


After reading up on Windows and how to build them, It mentioned I needed to associate the Window with a Frame as its owner. It didnt supply an actual example of this in practice, so I just gave it my best shot.

Window w = new Window(JFrame window);

Obviously this didnt work, it refered to JFrame as a variable, should this be where the JFrame's variable is placed?

It also mentioned a whole slew of other errors indicating this is not correct in the slightest.



So needless to say, I am not sure where to go from here.

Thanks a lot for the help
10 years ago