public class Ch5SampleGraphics_UF { public static void main(String[] args) { JFrame win; Container contentPane; Graphics gra; win = new JFrame("My First Rectangle"); win.setSize(300, 200); win.setLocation(100, 100); win.setVisible(true); contentPane = win.getContentPane(); contentPane.setBackground(Color.ORANGE); gra = contentPane.getGraphics(); gra.setColor(Color.blue); gra.drawRect(50, 50, 100, 30); } }
in my screen the frame and the content pane are the only thing that appears...
but the CONTENTS (the geometric shape that is supposed to be in the content pane) doesnt appear.
how can i solved this one?
anyway , what i did (for me to see it somehow) is i'm re-executing it again and again... and in some of the execution of the program, sometimes the shapes appear.. sometimes it doesnt