?? week.java~12~
字號:
package untitled1;import java.awt.*;import java.awt.event.*;import java.applet.*;import com.borland.jbcl.layout.*;import java.util.Date;public class week extends Applet { private Date today; boolean isStandalone = false; XYLayout xYLayout1 = new XYLayout(); Label label1 = new Label(); Label label2 = new Label(); TextField text1 = new TextField(); Button button1 = new Button(); /**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 week() { } /**Initialize the applet*/ public void init() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { label1.setFont(new java.awt.Font("Dialog", 0, 18)); label1.setText("日期"); this.setLayout(xYLayout1); label2.setFont(new java.awt.Font("Dialog", 0, 18)); label2.setText("年/月/日"); text1.setFont(new java.awt.Font("Dialog", 0, 18)); button1.setFont(new java.awt.Font("Dialog", 0, 18)); button1.setLabel("星期"); button1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(MouseEvent e) { button1_mouseClicked(e); } }); this.add(text1, new XYConstraints(129, 73, 130, -1)); this.add(label1, new XYConstraints(48, 63, 80, -1)); this.add(label2, new XYConstraints(48, 87, 80, -1)); this.add(button1, new XYConstraints(278, 69, 70, -1)); } /**Get Applet information*/ public String getAppletInfo() { return "Applet Information"; } /**Get parameter info*/ public String[][] getParameterInfo() { return null; } void button1_mouseClicked(MouseEvent e) { String strDate = text1.getText() ; int step1 = strDate.indexOf('/'); int step2 = strDate.lastIndexOf('/'); String year = strDate.substring(0,step1); String month = strDate.substring(step1+1,step2); String day = strDate.substring(step2+1); int Year = Integer.parseInt(year); int Month = Integer.parseInt(month); int Day = Integer.parseInt(day); today = new Date(Year,Month-1,Day); repaint(); } String getweek(){ int day = today.getDay(); switch(day){ case 0: return "Sunday"; case 1: return "Monday"; case 2: return "Tuesday"; case 3: return "Wensday"; case 4: return "Thursday"; case 5: return "Friday"; case 6: return "Saturday"; } return ""; } public void paint(Graphics g){ String strday = getweek(); g.drawString("today is"+strday,150,200); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -