本题程序在窗口内两个面板上分别绘制几何图形和显示图像,如题图,请按照注释要求补充完整程序。 程序代码如下: package drawgraphsample; import java.awt.*; import javax.swing.*; public class DrawGraphSample extends JFrame { private static final long serialVersionUID = 1L; JPanel jPanel1 = new JPanel(); JPanel jPanel2 = new JPanel(); GridLayout gridLayout1 = new GridLayout(); Image img; public DrawGraphSample(){ try { dgsInit(); } catch (Exception e) { e.printStackTrace(); } } private void dgsInit() throws Exception { this.setSize(new Dimension(700, 300)); //将本窗口内容窗格的布局管理器设置为gridLayout1。 ___________________________________________________________; this.getContentPane().add(jPanel1); this.getContentPane().add(jPanel2); //读取图像文件image.jpg。 img =______________________________; } public void paint(Graphics g) { g=jPanel1.getGraphics(); g.drawLine(10,10,30,30); g.drawLine(15,20,15,20); //绘制矩形(左上角坐标为(15,20),长为60、宽为30)。 _______________________________; g.fillRect(120,10,60,30); g.drawRoundRect(200,10,50,30,20,20); g.fillRoundRect(280,10,50,30,40,30); g.drawRoundRect(360,10,50,30,50,30); g.draw3DRect(20,60,80,60,true); g.fill3DRect(120,60,80,60,false); int Poly1_x[]={230,263,315,272,267}; int Poly1_y[]={60,40,115,94,126}; int Poly1_pts=Poly1_x.length; int Poly2_x[]={380,413,465,422,417}; int Poly2_y[]={60,40,115,94,126}; int Poly2_pts=Poly2_x.length; g.drawPolygon(Poly1_x,Poly1_y, Poly1_pts); g.fillPolygon(Poly2_x,Poly2_y, Poly2_pts); g.drawOval(30,150,60,60); g.fillOval(130,150,80,60); g.drawArc(210,150,100,60,35,-140); g.fillArc(310,150,100,60,35,65); g=jPanel2.getGraphics(); g.drawImage(img,0,0,this); } public static void main(String[] args) { DrawGraphSample dgs = new DrawGraphSample(); dgs.setDefaultCloseOperation(3); dgs.setTitle("左边绘图,右边显示图像"); dgs.setSize(700,300); //显示dgs窗口对象。 ___________________________; } }