Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can't find code in same file  RSS feed

 
Louis Lewis
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • 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:

 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Ron McLeod
Saloon Keeper
Posts: 1561
222
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
?
 
Ron McLeod
Saloon Keeper
Posts: 1561
222
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Oh crap, thanks.
 
Louis Lewis
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • 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.
 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Mark post as helpful
  • send pies
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!