Hey guys,
Quick one (*cough*) for you all!
Am writing an applicaiton that uses skins, and to do this I have overridden the paint method of a JWindow. All items are drawn onto this window using Label.paint(Graphics g) onto the content pane.
This works fine for AWT objects, painting them in the right place from a setx() & sety() method, however Swing objects only paint in the top left corner no matter how you set their position.
I got round this by using the Graphics.create(x, y, width, height) using the getx(), gety(), getheight() and getWidth() methods.
This works for JTextArea and JTextField but now when I try it for JSlider and JCheckBox it causes the display to fail to update on PC and on Mac OS X it crashes the postscript rendering engine.
I use the following for AWT:
if (awayButton.isVisible()) awayButton.paint(offScreenG);
and this for Swing:
Graphics smallBit = offScreenG.create(scroller.getX(),scroller.getY(),scroller.getWidth(),scroller.getHeight());
if(scroller.isVisible()) scroller.paint(smallBit);
Can anyone suggest a better way to place the Swing objects?
Or does anyone know a fix to the update problem?
Cheers!
Relisys
Quick one (*cough*) for you all!
Am writing an applicaiton that uses skins, and to do this I have overridden the paint method of a JWindow. All items are drawn onto this window using Label.paint(Graphics g) onto the content pane.
This works fine for AWT objects, painting them in the right place from a setx() & sety() method, however Swing objects only paint in the top left corner no matter how you set their position.
I got round this by using the Graphics.create(x, y, width, height) using the getx(), gety(), getheight() and getWidth() methods.
This works for JTextArea and JTextField but now when I try it for JSlider and JCheckBox it causes the display to fail to update on PC and on Mac OS X it crashes the postscript rendering engine.
I use the following for AWT:
if (awayButton.isVisible()) awayButton.paint(offScreenG);
and this for Swing:
Graphics smallBit = offScreenG.create(scroller.getX(),scroller.getY(),scroller.getWidth(),scroller.getHeight());
if(scroller.isVisible()) scroller.paint(smallBit);
Can anyone suggest a better way to place the Swing objects?
Or does anyone know a fix to the update problem?
Cheers!
Relisys