• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem drawOval() cant be found.

 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am trying out this tutorial to get this drawOval() to work but the compiler tells me that the drawOval cant be found.



"drawOval" is not part of any standard Java library, but your code as written suggests that you have created a class called drawOval that appears to be derived from a JPanel. Have you done this? Can we see the code for this class?
 
Ben Hultin
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Constructors do not have a return type do they?
 
Ben Hultin
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
stateChanged, not StateChanged.
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Case does matter in Java
Its always a good idea to have the API docs open and ready for reference while coding.
 
Ben Hultin
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you calling setD on the existing Oval_Sub_1 instance, or are you creating a new one?
 
Ben Hultin
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The instance you are creating on line 2 of that code snippet is never added to the user interface. It's different from the instance you are seeing, which is myPanel. You should use that one, but not declare it as a JPanel but as an Oval_Sub_1. Then you will be able to call its setD method.
 
Ben Hultin
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
I found some pretty shells, some sea glass and this lovely tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic