Hi!
Please help with following question, this is really something I have not a clue why this is happening.
I want to display BufferedImage in my JFrame. Now I need to load images first from disk.
if I execute this code in constructor of the program and after try to paint
in my paint function then nothing is painted.
=============== =
in constructor:
[code=java]
try {
whitePawn = ImageIO.read(ne w File("c:\\final big\\pawnwhite. gif"));
} catch (IOException e) {System.out.pri ntln(" Cannot load images");}
[/code]
in paint:[code=java]
g2d.drawImage(w hitePawn, 0,30, this);[/code]
=============== =
and if I put loading instruction in paint before drawImage() it works ok.
=============== =
all in paint:
[code=java]
try {
whitePawn = ImageIO.read(ne w File("c:\\final big\\pawnwhite. gif"));
} catch (IOException e) {System.out.pri ntln(" Cannot load images");}
g2d.drawImage(w hitePawn, 0,30, this);
[/code]
===============
Variable whitePawn is a field.
If needed I can post more code.
Thanks in advance for answering my stupid question.
Please help with following question, this is really something I have not a clue why this is happening.
I want to display BufferedImage in my JFrame. Now I need to load images first from disk.
if I execute this code in constructor of the program and after try to paint
in my paint function then nothing is painted.
=============== =
in constructor:
[code=java]
try {
whitePawn = ImageIO.read(ne w File("c:\\final big\\pawnwhite. gif"));
} catch (IOException e) {System.out.pri ntln(" Cannot load images");}
[/code]
in paint:[code=java]
g2d.drawImage(w hitePawn, 0,30, this);[/code]
=============== =
and if I put loading instruction in paint before drawImage() it works ok.
=============== =
all in paint:
[code=java]
try {
whitePawn = ImageIO.read(ne w File("c:\\final big\\pawnwhite. gif"));
} catch (IOException e) {System.out.pri ntln(" Cannot load images");}
g2d.drawImage(w hitePawn, 0,30, this);
[/code]
===============
Variable whitePawn is a field.
If needed I can post more code.
Thanks in advance for answering my stupid question.
Comment