• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

JPanel, no sytax error but error output

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • 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: 22002
107
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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: 3205
29
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
okey, thanks guys,
 
incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic