简体   繁体   中英

netbeans project stop checking new code

Okay, I'm creating a program from a single class, let's call it "John" class. So instead of starting from scratch, I create the "John" class by copying most code from "Dave" class( this class have similar setup but differ greatly in functionality), and then modify it greatly to suit my need.

The problem is, when I hit the 'run file' button, the program behave as if it was "Dave". it's ridiculous, I have changed lots of code, there's no way that "John" can looks like "Dave" now. So this must be netbeans doing. How to fix it?

edit:

so here's John:

/*
 * 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.");
        }
    }
}

and here's Dave:

/*
 * 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.");
        }
    }
}

在约翰的主要方法中

new PaintDemo(); // i.e. John's and Dave's main method initiate the same code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM