Import Java.awt.Color;
Import Java.awt.Graphics;
Import Java.awt.Graphics2D;
Import Javax.swing.JFrame;
Import Javax.swing.JPanel;
public class MyFrame extends JFrame {
/**
*
*/
Private static final long serialversionuid = 1L;
Class Mypanel extends JPanel {
/**
*
*/
Private static final long serialversionuid = 1L;
public void Paint (Graphics Graphics) {
Super.paint (graphics);
Graphics g2d = (graphics2d) Graphics;
G2d.setcolor (Color.Black);
G2d.draw3drect (0, 0, V, true);
}
}
Public MyFrame () {
This.add (New Mypanel ());
This.setsize (800, 600);
}
public static void Main (string[] args) {
MyFrame frame = new MyFrame ();
Frame.setdefaultcloseoperation (Jframe.exit_on_close);
Frame.setvisible (TRUE);
}
}
PS: One of the
public void Paint (Graphics Graphics) {
Super.paint (graphics);
Graphics g2d = (graphics2d) Graphics;
G2d.setcolor (Color.Black);
G2d.drawline (0, 0, 400, 500);
}
can also be replaced by
public void Paintcomponent (Graphics Graphics) {
Super.paintcomponent (graphics);
Graphics g2d = (graphics2d) Graphics;
G2d.setcolor (Color.Black);
G2d.drawline (0, 0, 400, 500);
}