📄 update.java~2~
字号:
package checkbox;import java.awt.*;import java.awt.event.*;import java.applet.*;import javax.swing.*;public class update extends Applet { boolean isStandalone = false; JCheckBox jCheckBox1 = new JCheckBox(); JCheckBox jCheckBox2 = new JCheckBox(); JCheckBox jCheckBox3 = new JCheckBox(); /**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 update() { } /**Initialize the applet*/ public void init() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { jCheckBox1.setText("圆形"); jCheckBox1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jCheckBox1_actionPerformed(e); } }); jCheckBox2.setText("正方形"); jCheckBox2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jCheckBox2_actionPerformed(e); } }); jCheckBox3.setText("扇形"); jCheckBox3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jCheckBox3_actionPerformed(e); } }); this.add(jCheckBox1, null); this.add(jCheckBox2, null); this.add(jCheckBox3, null); } /**Get Applet information*/ public String getAppletInfo() { return "Applet Information"; } /**Get parameter info*/ public String[][] getParameterInfo() { return null; } void jCheckBox1_actionPerformed(ActionEvent e) { repaint(); } public void paint(Graphics g){ g.clearRect(0,20,300,280); if(jCheckBox1.isSelected()) g.drawOval(60,60,30,30); if(jCheckBox2.isSelected()) g.drawRect(120,60,30,30); if(jCheckBox3.isSelected()) g.drawArc(180,60,30,30,0,130); } void jCheckBox3_actionPerformed(ActionEvent e) { repaint(); } void jCheckBox2_actionPerformed(ActionEvent e) { repaint(); } public void update(Graphics g){ paint(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -