Hi,
I am trying to run the program below. IT compiles fine and also runs. However, once the jframe loads and the container loads, I dont see any rectangle being drawn in there. Can anyone please help?
I am using jGrasp development environment with JDK 5.
I am running this on a Windows XP w/ SP2 OS
Thanks
Nihar
/*************** *************** *************** *************** ***********
Sample Program: Draw a rectangle on a frame window's content pane.
*************** *************** *************** *************** ***********/
import javax.swing.*; // for JFrame
import java.awt.*; // for Graphics and Container
import java.applet.*;
class Rectangle extends Applet {
public static void main(String [] args ) {
JFrame win;
Container contentPane;
Graphics g;
win = new JFrame("My First Rectangle");
win.setSize(300 , 300);
win.setLocation (100,100);
win.setVisible( true);
contentPane = win.getContentP ane();
g = contentPane.get Graphics();
g.drawRect(50,5 0,100,30);
}
}
I am trying to run the program below. IT compiles fine and also runs. However, once the jframe loads and the container loads, I dont see any rectangle being drawn in there. Can anyone please help?
I am using jGrasp development environment with JDK 5.
I am running this on a Windows XP w/ SP2 OS
Thanks
Nihar
/*************** *************** *************** *************** ***********
Sample Program: Draw a rectangle on a frame window's content pane.
*************** *************** *************** *************** ***********/
import javax.swing.*; // for JFrame
import java.awt.*; // for Graphics and Container
import java.applet.*;
class Rectangle extends Applet {
public static void main(String [] args ) {
JFrame win;
Container contentPane;
Graphics g;
win = new JFrame("My First Rectangle");
win.setSize(300 , 300);
win.setLocation (100,100);
win.setVisible( true);
contentPane = win.getContentP ane();
g = contentPane.get Graphics();
g.drawRect(50,5 0,100,30);
}
}
Comment