?? zhe.java~1~
字號:
package line;import java.awt.*;import java.awt.event.*;import java.applet.*;public class zhe extends Applet { int x1=-1,y1=-1; boolean flag=true; int x2,y2; boolean isStandalone = false; /**Get a parameter value*/ public String getParameter(String key, String def) { return isStandalone ? System.getProperty(key, def) : (getParameter(key) != null ? getParameter(key) : def); } /**Construct the applet*/ public zhe() { } /**Initialize the applet*/ public void init() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { this.setBackground(Color.white); this.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(MouseEvent e) { this_mousePressed(e); } }); } /**Get Applet information*/ public String getAppletInfo() { return "Applet Information"; } /**Get parameter info*/ public String[][] getParameterInfo() { return null; } void this_mousePressed(MouseEvent e) { flag=!flag; if(flag==true){ x1=e.getX(); y1=e.getY(); } else{ x2=e.getX(); y2=e.getY(); } if(x1!=-1 && y1!=-1) repaint(); } public void update(Graphics g){ paint(); } public void paint(Graphics g){ g.setColor(Color.red); g.drawLine(x1,y1,x2,y2); }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -