📄 choice.java~12~
字号:
package choice;import java.awt.*;import java.awt.event.*;import java.applet.*;import com.borland.jbcl.layout.*;public class choice extends Applet { boolean isStandalone = false; XYLayout xYLayout1 = new XYLayout(); Choice choice1 = new Choice(); /**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 choice() { } /**Initialize the applet*/ public void init() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { this.setLayout(xYLayout1); choice1.setFont(new java.awt.Font("Dialog", 0, 16)); choice1.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { choice1_itemStateChanged(e); } }); choice1.addHierarchyBoundsListener(new java.awt.event.HierarchyBoundsAdapter() { }); this.addHierarchyBoundsListener(new java.awt.event.HierarchyBoundsAdapter() { }); this.addMouseListener(new java.awt.event.MouseAdapter() { }); this.add(choice1, new XYConstraints(6, 9, 77, 20)); choice1.addItem("圆形"); choice1.addItem("正方形"); choice1.addItem("扇形"); choice1.addItem("椭圆"); } /**Get Applet information*/ public String getAppletInfo() { return "Applet Information"; } /**Get parameter info*/ public String[][] getParameterInfo() { return null; } public void paint(Graphics g){ switch(choice1.getSelectedIndex()){ case 0: g.drawOval(100,100,50,50); break; case 1: g.drawRect(100,100,50,50); break; case 2: g.drawArc(100,100,50,50,0,140); break; case 3: g.drawOval(100,100,50,70); break; } } void choice1_itemStateChanged(ItemEvent e) { repaint(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -