netbeans项目停止检查新代码
问题描述:
好的,我从一个类创建一个程序,我们称之为“John”类。因此,我从头开始创建“John”类,通过复制“Dave”类中的大部分代码(该类具有类似的设置,但功能差别很大),然后对其进行大量修改以适合我的需要。netbeans项目停止检查新代码
问题是,当我点击'运行文件'按钮时,程序的行为就好像它是“戴夫”一样。这很荒谬,我已经改变了很多代码,现在没有办法让“John”看起来像“Dave”。所以这一定是netbeans在做的。如何解决它?
编辑:
所以这里的约翰:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;
/**
*
* @author PCKhoi
*/
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
public class ImageBlink {
static DrawingCanvas canvas;
private BufferedImage bi;
private int w,h;
public ImageBlink() {
Frame f = new Frame("Click!");
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
URL imageSrc = null;
try {
imageSrc = new URL("what_I_think.jpg");
} catch (MalformedURLException ex) {
Logger.getLogger(ImageDemo.class.getName()).log(Level.SEVERE, null, ex);
}
try {
bi = ImageIO.read(imageSrc);
w = bi.getWidth(null);
h = bi.getHeight(null);
} catch (IOException e) {
System.out.println("Image could not be read");
System.exit(1);
}
canvas = new DrawingCanvas();
f.add(canvas, BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
public static void main(String[] args) {
new PaintDemo();
}
class DrawingCanvas extends Canvas implements MouseListener, MouseMotionListener {
private int x1=0,y1=0,x2=0,y2=0;
public Dimension getPreferredSize() {
return new Dimension(600,600);
}
public DrawingCanvas() {
super();
addMouseListener(this);
addMouseMotionListener(this);
setBackground(Color.white);
}
public void paint(Graphics g) {
Graphics2D g2D = (Graphics2D) g;
g2D.drawImage(bi,x2,y2,x2+w,y2+h,x1,y1,x1+w,y1+h,null);
}
public void mousePressed(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void mouseReleased(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void mouseClicked(MouseEvent e) {
x1 = x2;
y1 = y2;
x2 = (int)Math.random()*400;
y2 = (int)Math.random()*449;
canvas.repaint();
}
public void mouseDragged(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void mouseEntered(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void mouseExited(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void mouseMoved(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
}
和这里的戴夫:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;
/**
*
* @author PCKhoi
*/
import java.awt.*;
import java.awt.event.*;
public class PaintDemo {
static DrawingCanvas canvas;
private Stroke lineStroke;
public PaintDemo() {
Frame f = new Frame("Stroke a line!");
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
canvas = new DrawingCanvas();
lineStroke = new BasicStroke(2.f);
f.add(canvas, BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
public static void main(String[] args) {
PaintDemo pd = new PaintDemo();
}
class DrawingCanvas extends Canvas implements MouseListener, MouseMotionListener {
private int x1=0,y1=0,x2=200,y2=200;
public Dimension getPreferredSize() {
return new Dimension(300,300);
}
public DrawingCanvas() {
super();
addMouseListener(this);
addMouseMotionListener(this);
setBackground(Color.white);
}
public void paint(Graphics g) {
Graphics2D g2D = (Graphics2D) g;
g2D.setStroke(lineStroke);
g2D.drawLine(x1, y1, x2, y2);
}
public void mousePressed(MouseEvent e) {
x1 = e.getX();
y1 = e.getY();
x2 = x1;
y2 = y1;
System.out.println("x1: "+x1+"y1: "+y1);
canvas.repaint();
}
public void mouseReleased(MouseEvent e) {
x2 = e.getX();
y2 = e.getY();
System.out.println("x2: "+x2+"y2: "+y2);
canvas.repaint();
}
public void mouseClicked(MouseEvent e) {
canvas.repaint();
}
public void mouseDragged(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void mouseEntered(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void mouseExited(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void mouseMoved(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
}
你能张贴代码 – 2010-10-11 09:13:41
我不是很家庭iar与Netbeans,但我认为你应该检查'运行文件'按钮是否实际运行文件(而不是,以前运行的文件或其他东西) – Jorn 2010-10-11 09:16:14
当我右键单击时,此“运行文件”按钮位于菜单内文件。它和其他班级一起工作得很好。我创建了许多小程序,它们在一个大项目文件夹下运行。 – Khoi 2010-10-11 09:23:36