public void actionPerformed(ActionEvent e){
  fdlg.setVisible(true);
  chooseField.setText(fdlg.getDirectory()+fdlg.getFile());
  URL=fdlg.getDirectory()+fdlg.getFile();
  
  repaint();
}
  public void paint(Graphics g){
  
      paintImage1=new paintImage(URL);
  
      n = new DrawPanel(new Dimension(400,300)); 
  n.removeAll();
  n.repaint();
  n.setImage(n.getToolkit().getImage("c:\\"+nowShow+"."+"jpg")); 
  n.setLayout(null); 
  
  paintPanel.add(n);
  mainFrame.getContentPane().add(n,BorderLayout.EAST); 
  mainFrame.setSize(680,280); 
  mainFrame.show();
  }

解决方案 »

  1.   

    你用什么跟的,repaint()不去paint()去哪了
      

  2.   

    我再paint()里面建立了断点,但是怎么也没反映,这不是说明repaint()没有调用paint();
      

  3.   

    我不知道怎么回事,我想问问repaint()调用的是父类的paint(),还是本身的paint()方法
      

  4.   

    要先调用super.paint(Graphics g);
      

  5.   

    (你的这个类是继承自java.awt.Component或Component的子类吗? 我推论答案是的)paint()是在Component被绘制的时候被调用的。你确定你调试的时候你的这个Component已经放在某个Frame或Dialog里了吗?并且Frame或Dialog被setVisile(true)了?如果没有那么将它添加到Frame或Dialog里,并且设置Frame或Dialog的visible为true。这样在显示的时候paint()就会被调用了。
      

  6.   

    如果设置过这么个属性:
    setIgnoreRepaint(true);
    再描画是会被无视掉的。
    看看跟它有关系否?
      

  7.   

    问题解决,repaint()迁套着,所以不执行