別段隠す物でもないので、(^^; ソース載せました。。。ダチョウなプログラムでごめんなさい。JAVA初期コーディング時の物です。
| <APPLET code="ViewTime4.class" width="190" height="38"> <PARAM name="CLOCK_TIME" value="TimesRoman,14,A0A0FF,F8F8F8,P,130,20"> <PARAM name="CLOCK_DATE" value="TimesRoman,18,FFA0A0,FFFFFF,B,6,20"> <PARAM name="COPYRIGHT" value="TimesRoman,11,60A060,FFFFFF,P,6,32"> <PARAM name="CORNER" value="E0E0E0,B0B0B0"> </APPLET> |
|
| import java.applet.*; import java.awt.*; import java.net.*; import java.util.*; public class ViewTime4 extends Applet implements Runnable { // **** 時間のパラメーター String pFontName; int pFontSize; Color pBColor, pFColor; int pX, pY; int pStyle; Font pFont; // **** 日付のパラメーター String p2FontName; int p2FontSize; Color p2BColor, p2FColor; int p2X, p2Y; int p2Style; Font p2Font; // **** Copyright String p3FontName; int p3FontSize; Color p3BColor, p3FColor; int p3X, p3Y; int p3Style; Font p3Font; // **** Box line Color rucolor; Color ldcolor; String copyright; // Dimension WinSize; int WinXs, WinYs; Graphics dbuffer; Image offscreen; URL linkurl; Thread mythread = null; // MainLoop -------------------------------------------------------- public void run() { while (true) { try { Thread.sleep(500); } catch (java.lang.InterruptedException e) {} this.repaint(); } } // THREAD Start ---------------------------------------------------- public void start() { if (mythread == null) { mythread = new Thread(this); mythread.start(); } } // THREAD Stop ----------------------------------------------------- public void stop() { if (mythread != null) { mythread.stop(); mythread=null; } } // Class Module Init ----------------------------------------------- public void init() { String sStyle; String s2Style; String s3Style; int i, l; Rectangle AppBorder = bounds(); WinXs = AppBorder.width; WinYs = AppBorder.height; // WinSize = size(); try { linkurl = new URL("http://village.infoweb.or.jp/~fwgl8914/"); } catch (MalformedURLException e) { System.out.println("Error locating URL address."); } // ***** 時間表示のパラメーター解析 StringTokenizer tk = new StringTokenizer(getParameter("CLOCK_TIME"),","); pFontName = tk.nextToken(); pFontSize = Integer.parseInt(tk.nextToken()); pFColor = new Color(Hex2Value(tk.nextToken(),0,6)); pBColor = new Color(Hex2Value(tk.nextToken(),0,6)); sStyle = tk.nextToken(); pX = Integer.parseInt(tk.nextToken()); pY = Integer.parseInt(tk.nextToken()); pStyle = Font.PLAIN; if (sStyle=="B") pStyle=Font.BOLD; else if (sStyle=="I") pStyle=Font.ITALIC; else if (sStyle=="BI") pStyle=Font.BOLD+Font.ITALIC; pFont = new Font(pFontName, pStyle, pFontSize); // ***** 日付表示のパラメーター解析 StringTokenizer tk2 = new StringTokenizer(getParameter("CLOCK_DATE"),","); p2FontName = tk2.nextToken();; p2FontSize = Integer.parseInt(tk2.nextToken()); p2FColor = new Color(Hex2Value(tk2.nextToken(),0,6)); p2BColor = new Color(Hex2Value(tk2.nextToken(),0,6)); s2Style = tk2.nextToken(); p2X = Integer.parseInt(tk2.nextToken()); p2Y = Integer.parseInt(tk2.nextToken()); p2Style = Font.PLAIN; if (s2Style=="B") p2Style=Font.BOLD; else if (s2Style=="I") p2Style=Font.ITALIC; else if (s2Style=="BI") p2Style=Font.BOLD+Font.ITALIC; p2Font = new Font(p2FontName, p2Style, p2FontSize); // ***** Copyright StringTokenizer tk3 = new StringTokenizer(getParameter("COPYRIGHT"),","); p3FontName = tk3.nextToken();; p3FontSize = Integer.parseInt(tk3.nextToken()); p3FColor = new Color(Hex2Value(tk3.nextToken(),0,6)); p3BColor = new Color(Hex2Value(tk3.nextToken(),0,6)); s3Style = tk3.nextToken(); p3X = Integer.parseInt(tk3.nextToken()); p3Y = Integer.parseInt(tk3.nextToken()); p3Style = Font.PLAIN; if (s3Style=="B") p3Style=Font.BOLD; else if (s3Style=="I") p3Style=Font.ITALIC; else if (s3Style=="BI") p3Style=Font.BOLD+Font.ITALIC; p3Font = new Font(p3FontName, p3Style, p3FontSize); copyright = "(C)WinWin Room JAVA Clock Ver1.40"; // ***** Corner StringTokenizer tk4 = new StringTokenizer(getParameter("CORNER"),","); rucolor = new Color(Hex2Value(tk4.nextToken(),0,6)); ldcolor = new Color(Hex2Value(tk4.nextToken(),0,6)); // ***** 描画用ダブルバッファの作成 offscreen = createImage(WinXs, WinYs); dbuffer = offscreen.getGraphics(); dbuffer.setColor(pBColor); dbuffer.fillRect(0,0,WinXs, WinYs); } // Rapaint --------------------------------------------------------- public void paint(Graphics g) { int hh, mm, ss, yy, dd; String shh, smm, sss, syy, sdd; int tmp; int x1, y1, x2, y2, xs, ys; Date dt = new Date(); // ***** 時間表示 hh = dt.getHours(); mm = dt.getMinutes(); ss = dt.getSeconds(); shh = Integer.toString(hh); if (shh.length()==1) shh="0"+shh; smm = Integer.toString(mm); if (smm.length()==1) smm="0"+smm; sss = Integer.toString(ss); if (sss.length()==1) sss="0"+sss; dbuffer.setColor(pBColor); dbuffer.fillRect(0, 0, WinXs, WinYs); dbuffer.setFont(pFont); dbuffer.setColor(pFColor); dbuffer.drawString(shh+":"+smm+":"+sss, pX, pY); // ***** 日付表示 yy = dt.getYear(); mm = dt.getMonth()+1; dd = dt.getDate(); if (yy>90) yy+=1900; else yy+=2000; syy = Integer.toString(yy); smm = Integer.toString(mm); sdd = Integer.toString(dd); dbuffer.setFont(p2Font); dbuffer.setColor(p2FColor); dbuffer.drawString(syy+"/"+smm+"/"+sdd, p2X, p2Y); // ***** Copyright dbuffer.setFont(p3Font); dbuffer.setColor(p3FColor); dbuffer.drawString(copyright, p3X, p3Y); // ***** Box x1 = 0; x2 = WinXs-1; y1 = 0; y2 = WinYs-1; xs = WinXs; ys = WinYs; dbuffer.setColor(rucolor); dbuffer.fillRect(x1, y1, 2, ys); dbuffer.fillRect(x1, y1, xs, 2); dbuffer.setColor(ldcolor); dbuffer.fillRect(x1, y2-1, xs, 2); dbuffer.fillRect(x2-1, y1, 2, ys); g.drawImage(offscreen, 0, 0, this); } // update ---------------------------------------------------------- public void update(Graphics g) { paint(g); } // MouseAction------------------------------------------------------ public boolean mouseDown(Event e, int x, int y) { showStatus("Link WinWin Room"); getAppletContext().showDocument(linkurl); return true; } // Hex2Values ------------------------------------------------------ private int Hex2Value(String HexS, int sp, int ll) { int i; int rts; int num; String s = new String(HexS); rts = 0; for (i=0; i<ll; i++) { num = 0; switch (HexS.charAt(sp+i)) { case '0': num=0; break; case '1': num=1; break; case '2': num=2; break; case '3': num=3; break; case '4': num=4; break; case '5': num=5; break; case '6': num=6; break; case '7': num=7; break; case '8': num=8; break; case '9': num=9; break; case 'A': num=10; break; case 'B': num=11; break; case 'C': num=12; break; case 'D': num=13; break; case 'E': num=14; break; case 'F': num=15; break; } rts = rts * 16 + num; } return rts; } } |