📄 fuzzy_identity_frame.java~66~
字号:
package fuzzy_identity;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;import java.util.*;class point{ int x,y; point(int a,int b) {x=a;y=b;}}class Image_jpanel extends JPanel{ private Vector vp=null; private point p1,p2; private int count; public void vec(Vector v) { vp=v; } public void paint(Graphics g) { g.setColor(Color.yellow); g.fillRect(0,0,100,100); g.setColor(Color.black); if(vp==null) count=0; else count=vp.size(); for(int i=0;i<count-1;i++) { p1=(point)vp.elementAt(i); p2=(point)vp.elementAt(i+1); if(p2.x==10000&&p2.y==10000) continue; if(p1.x==10000&&p1.y==10000) continue; g.drawLine(p1.x,p1.y,p2.x,p2.y); } }}public class Fuzzy_Identity_Frame extends JFrame { JPanel contentPane; Image_jpanel image_jpanel; XYLayout xYLayout1 = new XYLayout(); point p; Point cutflag = new Point(10000,10000);//截断标志 int x,y; Vector v=new Vector(); //Construct the frame public Fuzzy_Identity_Frame() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { x=y=0; contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(xYLayout1); this.setResizable(false); this.setSize(new Dimension(300, 200)); this.setTitle("模糊识别"); image_jpanel=new Image_jpanel(); image_jpanel.addMouseMotionListener(new Fuzzy_Identity_Frame_image_jpanel_mouseMotionAdapter(this)); image_jpanel.addMouseListener(new Fuzzy_Identity_Frame_image_jpanel_mouseAdapter(this)); contentPane.add(image_jpanel,new XYConstraints(100, 20, 100, 100)); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } void image_jpanel_mouseDragged(MouseEvent e) { x=e.getX(); y=e.getY(); p=new point(x,y); v.addElement(p); image_jpanel.vec(v); image_jpanel.repaint(); } void image_jpanel_mousePressed(MouseEvent e) { x=e.getX(); y=e.getY(); p=new point(x,y); v.addElement(p); image_jpanel.vec(v); image_jpanel.repaint(); } void image_jpanel_mouseReleased(MouseEvent e) { x=e.getX();y=e.getY();p=new point(x,y); v.addElement(p); }}class Fuzzy_Identity_Frame_image_jpanel_mouseMotionAdapter extends java.awt.event.MouseMotionAdapter { Fuzzy_Identity_Frame adaptee; Fuzzy_Identity_Frame_image_jpanel_mouseMotionAdapter(Fuzzy_Identity_Frame adaptee) { this.adaptee = adaptee; } public void mouseDragged(MouseEvent e) { adaptee.image_jpanel_mouseDragged(e); }}class Fuzzy_Identity_Frame_image_jpanel_mouseAdapter extends java.awt.event.MouseAdapter { Fuzzy_Identity_Frame adaptee; Fuzzy_Identity_Frame_image_jpanel_mouseAdapter(Fuzzy_Identity_Frame adaptee) { this.adaptee = adaptee; } public void mousePressed(MouseEvent e) { adaptee.image_jpanel_mousePressed(e); } public void mouseReleased(MouseEvent e) { adaptee.image_jpanel_mouseReleased(e); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -