Re: Why, won't this update?
What exactly do you mean when you say it doesn't update? Why are you using paint() instead of paintComponent() and a call to super.paintComponent()? Why are you finalizing the Graphics instance before you're done using it?
Re: Why, won't this update?
Quote:
Originally Posted by
Jerba
Okay, basically i'm using an object to get some ints to print out but it won't update...
You're doing a couple of things wrong here. Let's dive in:
Quote:
GameLoader Class (extends jframe)
Code :
public void paint(Graphics g) {
Don't draw directly in a JFrame. The drawing instead should be inside of the paintComponent(...) method of a JPanel or other class that derives from JComponent. This way you don't lose the benefits of Swing drawing including double buffering, and this way you don't accidently misdraw child components or borders.
Quote:
Code :
Graphics2D g2 = (Graphics2D) g;
Image img1 = Toolkit.getDefaultToolkit().getImage("sprites/background.gif");
Don't read in files from within the paint or paintComponent methods as this is unnecessary -- why read in a file many times when once will do? and also this will slow down the responsiveness of the program greatly. Read it in the constructor or someother initialization code.
Quote:
Code :
g2.drawImage(img1, 0, 0, this);
g2.finalize();
finalize? where did that come from? This is not only unnecessary but is also very dangerous. Just don't do this. Ever.
Quote:
Code :
// Start Text
PlayerAssistant getPA = new PlayerAssistant();
Don't do program logic from within paint or paintComponent. Realize that you do not have control over when or if this method gets called.
Re: Why, won't this update?
Quote:
Originally Posted by
Jerba
FIIIIIIIIIIIIIIIIIIIIIXEEEEEEED
Thanks for deleting your question. This is inconsiderate to those who put time in to help you, not to mention future users of this forum who may have the same problem.
Instead wouldn't it have better to have posted your fix as a reply?
Re: Why, won't this update?
Well said curmudgeon. The mod team has access to post edits, and in cases such as this have the option to revert the edited post, which I have elected to do.
Jerba, I recommend to avoid editing your posts to entirely remove your questions in the manner you have