📄 randomexample.java~4~
字号:
package untitled1;import java.awt.*;import java.awt.event.*;import java.applet.*;public class randomexample extends Applet { int i,j,k; int x,y; Color mycolor; 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 randomexample() { } /**Initialize the applet*/ public void init() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { this.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(MouseEvent e) { this_mouseClicked(e); } }); } /**Get Applet information*/ public String getAppletInfo() { return "Applet Information"; } /**Get parameter info*/ public String[][] getParameterInfo() { return null; } void this_mouseClicked(MouseEvent e) { x = e.getX() ; y = e.getY() ; i = (int)(255*Math.random()); j = (int)(255*Math.random()); k = (int)(255*Math.random()); repaint(); } public void paint(Graphics g){ mycolor = new Color(i,j,k); g.fillOval(x-10,y-10,20,20); g.drawString(String.valueOf(i)+" "+String.valueOf(j)+" "+String.valueOf(k),x-10,y+20); } public void update(Graphics g){ paint(g); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -