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

background buffered image

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So i have created a jscrollpane with a panel with an image as the background, it updates and changes the image size, but does upon an event trigger it reverts back to the original image size!, how do i stop this?, have i got the inheritance correct!? have i got the object hireachy right!?
 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does a user do with the program to see the problem?
When I used it I got this error:
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: ""
It looks the the program should check for input before trying to parse empty input.
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know about inheritance and object hierarchy -- but they shouldn't have anything to do with drawing a background image anyway. You might want to have a look at our FAQ entry on just that topic: Background Image On JPanel, because it's a lot simpler than what you're trying to do there and from what you say, it's more reliable.
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

So i have created a jscrollpane with a panel with an image as the background



So what's with all the code? Post a proper SSCCE when you ask a question.

To test how to use a panel with an image all you need is a frame with the scroll pane, panel and image.

Get a simple version working first before trying to use it in your real program.

There are many things wrong with the code:

1. Variable names should NOT start with an upper case character
2. Method names should NOT start with an upper case character
3. Don't use static variables.
4. Don't use static methods
5. Don't use getGraphics() to do custom painting.

I suggest you start by reading the Swing tutorial on Custom Painting. The tutorial examples will show you how to:

1. do custom painting by overriding the paintComponent() method of a JPanel
2. better structure your code so you don't have static variables and methods (except for the initials creation of the frame)
 
Andrew Robertson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem was complex and required the code to solve the problem, of which i have done!
 
Andrew Robertson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I mean i have solved my problem, and as for Oracle documents, the basic stuff is good, because the examples are basic, but when going into advanced issues, the surround the example code with heaps of other code, camouflaging it!
 
Norm Radder
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

i have solved my problem,  


Could you post the working code?
 
We find this kind of rampant individuality very disturbing. But not this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic