• 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

JPanel, no sytax error but error output

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys,
i followed every step in this tutorial part 1 part 2 but the output was not good,
even though i don't understand his language i followed what he did.

here is the output:


notice the gap between the picture and the right side of the panel?

here is my code(ImagePanel.java):


and this is my jframe gui code:


can anyone correct my error? ^^
 
Sheriff
Posts: 22781
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

borj bersas wrote:


There is your problem. You are using a GroupLayout that does not fill the entire contents. If you would use a BorderLayout instead and add the component using BorderLayout.CENTER then the image panel would be stretched.

It's quite clear that your code is generated by a GUI builder. I suggest you stop doing that and read Sun's tutorial on Swing, especially the part about layout managers. That way you will understand better what is happening.
 
borj bersas
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes i am using the netbeans gui builder,
but why is that the man in the tutorial was using netbeans gui builder too
and find no error output?

that means he also use GroupLayout right?
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

borj bersas wrote:yes i am using the netbeans gui builder,



Hi , I have one suggestion which is like I am giving you as I have faced these problems ... never ever user codes that are generated by IDEs as it will be difficult for you to understand and it may not work properly if you shift to some other IDEs. So start writing your own code and use sun forum for writing the code.
 
borj bersas
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well it seems i have to start the hard coding, by the way, how can i use the
BorderLayout and BorderLayout.Center?
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

by the way, how can i use the BorderLayout and BorderLayout.Center?



Read the section from the Swing tutorial on How to Use Border Layout
 
borj bersas
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
okey, thanks guys,
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic