• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

background on Java Desktop Application

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created a Java Desktop Application with NetBeans 6.9 IDE. The application consists of several panels. Three of these panels have simple rectangles drawn on them with different fill colors. The other panels have a jFreeChart drawn on them. What I would like to do is to place a background image behind everything let all of the panels have transparent backgrounds so the image will show through. Can anyone take me through how to do this using the NetBeans IDE? Thanks

 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jesse Miller wrote:I have created a Java Desktop Application with NetBeans 6.9 IDE. The application consists of several panels. Three of these panels have simple rectangles drawn on them with different fill colors. The other panels have a jFreeChart drawn on them. What I would like to do is to place a background image behind everything let all of the panels have transparent backgrounds so the image will show through.



To have a JPanel show through, usually you just call setOpaque(false) on the JPanel. To show a background image, the override the component's paintComponent method and draw the image there as is shown in this forum's FAQ (for a JPanel, but the technique is the same).


Can anyone take me through how to do this using the NetBeans IDE?


Not me as I don't use code-generation, and I strongly urge you, at this stage in your Swing education, to do the same.

Luck!
 
Jesse Miller
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I understand your opposition to code-generation. I am trying to scrap my generated code and just start from the ground up. The frame that all of these panels are in is re sizable, I need to make each of the panels re size with the frame. Any ideas what layout I could use to do this?
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jesse Miller wrote:Ok, I understand your opposition to code-generation. I am trying to scrap my generated code and just start from the ground up. The frame that all of these panels are in is re sizable, I need to make each of the panels re size with the frame. Any ideas what layout I could use to do this?



Yep, the first chapter you should read in the Swing tutorials is the one on layout managers as these will do all of this for you if properly used. But please realize that a concept that may not be well mentioned in the tutorials is that we often nest containers (usually JPanels), each with their own layout manager in order to achieve the layout desired.
 
Jesse Miller
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, which layout manager would handle automatic resizing of jPanels inside jFrames best?
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jesse Miller wrote:Ok, which layout manager would handle automatic resizing of jPanels inside jFrames best?



This is an unanswerable question as a) it all depends on the situation and b) we usually use more than one layout manager in an app, often nesting JPanels each that use their own layout manager. If you study the tutorial as suggested above, I think that it will all be clear to you.
 
Oh, sure, you could do that. Or you could eat some pie. While reading this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!