• Post Reply Bookmark Topic Watch Topic
  • New Topic

background buffered image

 
Andrew Robertson
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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!?
 
Norm Radder
Bartender
Posts: 1526
14
  • Mark post as helpful
  • send pies
  • 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.
 
Paul Clapham
Sheriff
Posts: 21881
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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.
 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Mark post as helpful
  • send pies
  • 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: 7
  • Mark post as helpful
  • send pies
  • 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: 7
  • Mark post as helpful
  • send pies
  • 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
Bartender
Posts: 1526
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have solved my problem, 

Could you post the working code?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!