• 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

Can't find code in same file

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I'm trying to use Darryl's proportionate panel (and also his stretch icon class) for a chess program. I copied the two classes (ProportionatePanel and ProportionateDimension) into the end of my class, and then attempted to initialize a panel in the same way as used in the example program. However, netbeans keeps telling me that it can't find "class ProportionatePanel, which seems weird to me since the class is literally sitting right there in the same file. Anyone know what could be going wrong? Here is my code:

 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, no, there isn't a class named ProportionatePanel declared in that file. Perhaps you thought the class starting at line was named ProportionatePanel?
 
Louis Lewis
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well when it says "class ProportionalPanel extends JPanel," isn't that a new class? And if it isn't, then how am I supposed to initialize a JPanel as a proportionate panel? I though I essentially just copied the example, where it says "JPanel xxx = new ProportionatePanel(5,1). I just ignored the arguments since I didn't understand them.
 
Marshal
Posts: 4501
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Louis Lewis wrote:Well when it says "class ProportionalPanel extends JPanel," isn't that a new class? And if it isn't, then how am I supposed to initialize a JPanel as a proportionate panel? I though I essentially just copied the example, where it says "JPanel xxx = new ProportionatePanel(5,1). I just ignored the arguments since I didn't understand them.

 
Louis Lewis
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
?
 
Ron McLeod
Marshal
Posts: 4501
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These two class names are not the same:

ProportionalPanel
ProportionatePanel
 
Louis Lewis
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh crap, thanks.
 
Louis Lewis
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
However, now that I fixed the typo, I initialized the panel as follows:



But the panel does not remain proportionate when resized. Am I using the class correctly? I assumed the arguments were just the aspect ratio to be preserved, but now I'm not sure.
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure what the ProportionalPanel is supposed to do, but it is not that easy. The size needs to be based on the space available in the parent Container.

Check out this example for one approach.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic