import java.applet.Applet; import java.awt.*; import java.awt.event.*; import javax.swing.*; /* */ public class ExeInput extends Applet implements MouseListener ,MouseMotionListener { private int width = 300; private int height = 300; private Point before; private boolean checkPressed = false; private ArrayImage img; private Label edgeL; public void init() { img =new ArrayImage( createImage(280,280),280,280); addMouseListener(this); addMouseMotionListener(this); before = null; // setLayout(null); edgeL = new Label("端の数:"); edgeL.setLocation(0,0); add(edgeL); } public void mouseDragged(MouseEvent e) { // System.out.println("mo"); if(checkPressed == true && before != null) { System.out.println("moce"); if(e.getX()<280 && e.getY()<280 && e.getX()>0 && e.getY() >0) { img.drawLine((int)before.getX(),(int)before.getY(),e.getX(),e.getY()); img.baseXY(e.getX(),e.getY(),true); img.imageXY(e.getX(),e.getY()); before = e.getPoint(); repaint(); } } } public void mouseMoved(MouseEvent e) { } public void update(Graphics g) { paint(g); } public void paint(Graphics g) { g.drawImage(img.createImage(),0,0,this); } public void mouseClicked(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mousePressed(MouseEvent e){checkPressed = true;System.out.println("WW"); before = e.getPoint();} public void mouseReleased(MouseEvent e) { checkPressed = false;System.out.println("YY");before = null;repaint(); Pattern pat = new Pattern(img.getArray(),img.Width(),img.Height()); int a = pat.searchEdge(); edgeL.setText("端の数:"+a); } }