• 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
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

How to make a "static background" on the scrollpane ?  RSS feed

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I have a problem when the scrollpane are too long. Just look at the image

How to make the image stay the same while I scroll down the panel ?

This is part of my code

And this is how I set the background image


I also have tried on my own, two trial.
First, I search wheter I can set the background on the frame instead, and the result is none. It is not possible

Second I tried to make a new panel, and put this as my background panel, and add the scrollpane to this panel (before, I put the scrollpane on the frame). But, the problem comes from the unmoving scrollpane/ Failed
I tried another alternative as to set the layout of this panel as border layout, the scrollpane is working fine, but the background cannot be seen even though I setOpaque(false) this panel.

Please help me. Thank You.
Screenshot-from-2018-10-23-15-36-55.png
[Thumbnail for Screenshot-from-2018-10-23-15-36-55.png]
look, the background image stop there.
 
Marshal
Posts: 64172
215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you adding that image to the scroll pane? How are you adding that scroll pane to the frame? Where do all the Japanese→English translations come from?
 
Lando Chan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is a long code and I do not think that other part of code will affect the solution in any way. In short I use combination of ArrayList<TextArea> for those japanese english translation and ArrayList<JButton> for those delete button. and adding all of them in sequence to the gridpanel.
 
Lando Chan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adding the image ? Do not you see ? I use paintComponent to draw that image.
 
Lando Chan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is may be unclear but f is a frame.
This is the code which I have included in the previous post
 
Rancher
Posts: 3034
22
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to paint the image on the viewport of the scroll pane and make your panel transparent:

 
Lando Chan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You, It worked.
 
A teeny tiny vulgar attempt to get you to buy our stuff
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!