📄 oval.java~3~
字号:
package updot;import java.awt.*;import java.awt.event.*;import java.applet.*;public class oval extends Applet { boolean isStandalone = false; int i; int a[]={0,0,255}; boolean flag[]={true,true,false}; Color mycolor; int x,y; /**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 oval() { } /**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; } public void update(Graphics g){ paint(g); x=x-10; y=y-10; } void this_mousePressed(MouseEvent e) { x=e.getX(); y=e.getY(); for(i=0;i<3;i++){ if(a[i]<=10) flag[i]=true; if(a[i]>=245) flag[i]=false; if(flag[i]==true) a[i]+=10; else a[i]-=10; } repaint(); } public void paint(Graphics g){ mycolor=new Color(a[0],a[1],a[2]); g.setColor(mycolor); g.fillOval(x-10,y-10,20,20); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -