• Post Reply Bookmark Topic Watch Topic
  • New Topic

JPanel, no sytax error but error output  RSS feed

 
borj bersas
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? ^^
 
Rob Spoor
Sheriff
Posts: 21052
85
Chrome Eclipse IDE Java 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?
 
Rohit Kedia
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?
 
Rob Camick
Ranch Hand
Posts: 2788
12
  • 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,
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!