Is it possible to draw on a picture after loading and before displaying it?

Hi to all :)

I intend to write a small applet(connected with a server using RMI, but that's not important :) ) that represents the 'tic-tac-toe' game.

I've planned to create 3 pictures - blank, containing a circle and containing a cross.

Then I think to used 9 JButton-s and set the blank pic as an Icon for the JButton. An action event listener will change the picture to circle ot cross and so on...

I would like to draw a line over the 3 pictures for the winner at the end of the game.

Is it possible to load a circle or cross picture, then draw a horizontal/vertical/diagonal line on it at runtime and after that set it as an Icon for the Jbutton ?

Thanks in advance. Take care :)

[731 byte] By [balkanskia] at [2007-11-27 8:37:42]
# 1

To my knowledge, you can't overlay icons on a JButton without subclassing it and overriding paintComponent. In that case, II suppose you could try painting over all your buttons with something like:parentContainer = new JPanel() {

@Override

protected void paintComponent(Graphics g) {

super.paintComponent(g);

drawLine(0, 0, 100, 100); //etc...

}

};

parentContainer.add(myFirstButton);

//etc.

RATiXa at 2007-7-12 20:34:59 > top of Java-index,Java Essentials,Java Programming...