• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79969
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 3324
32
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You, It worked.
 
Now I am super curious what sports would be like if we allowed drugs and tiny ads.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic