Ask Question Forum:
C
O
M
P
U
T
E
R
2
8
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Y-position of the mouse cursor
Attachment:===
Javac and Java

I copy the source from
http://java.sun.com/applets/jdk/1.4/demo/applets/GraphicsTest/example1.html
and name it as GraphicsTest.java, and run it my working dir, it also get the similar error
Could you it at your side. GraphicsCard.class and GraphicsPanel.class can be generated but not GraphicsTest.class. The error is similar to my previouse post..Case sensitive is already checked and
no problem at all
Best Regards
Duncan
[b]GraphicsTest.java [/b]/* * @(#)GraphicsTest.java 1.10 99/08/04 * * Copyright (c) 1997, 1998 Sun Microsystems, Inc. All Rights Reserved. * * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use, * modify and redistribute this software in source and binary code form, * provided that i) this copyright notice and license appear on all copies of * the software; and ii) Licensee does not utilize the software in a manner * which is disparaging to Sun. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * This software is not designed or intended for use in on-line control of * aircraft, air traffic, aircraft navigation or aircraft communications; or in * the design, construction, operation or maintenance of any nuclear * facility. Licensee represents and warrants that it will not use or * redistribute the Software for such purposes. */import java.awt.*;import java.util.*;import java.awt.event.*;import java.applet.Applet;class GraphicsPanel extends Panel { ActionListener al; ItemListener il; public GraphicsCards cards; GraphicsPanel(EventListener listener) { al = (ActionListener)listener; il = (ItemListener)listener; setLayout(new BorderLayout()); add("Center", cards = new GraphicsCards()); Panel p = new Panel(); //p.setLayout(new BorderLayout()); Button b = new Button("next"); b.addActionListener(al); p.add(b); b = new Button("previous"); b.addActionListener(al); p.add(b); p.add(new Label("go to:", Label.RIGHT)); Choice c = new Choice(); c.addItemListener(il); p.add(c); c.addItem("Arc"); c.addItem("Oval"); c.addItem("Polygon"); c.addItem("Rect"); c.addItem("RoundRect"); add("North", p); setSize(400, 400); } public Dimension getPreferredSize() { return new Dimension(200, 100); }}public class GraphicsTest extends Appletimplements ActionListener, ItemListener { GraphicsPanel mainPanel; public void init() { setLayout(new BorderLayout()); add("Center", mainPanel = new GraphicsPanel(this)); } public void destroy() { remove(mainPanel); } public void actionPerformed(ActionEvent e) { String arg = e.getActionCommand(); if ("next".equals(arg)) { ((CardLayout)mainPanel.cards.getLayout()).next(mainPanel.cards); } else if ("previous".equals(arg)) { ((CardLayout)mainPanel.cards.getLayout()).previous(mainPanel.cards); } } public void itemStateChanged(ItemEvent e) { ((CardLayout)mainPanel.cards.getLayout()).show(mainPanel.cards,(String)e.getItem()); } public static void main(String args[]) { AppletFrame.startApplet("GraphicsTest", "Graphics Test", args); } public String getAppletInfo() { return "An interactive demonstration of some graphics."; }} // end class GraphicsTestclass GraphicsCards extends Panel { public GraphicsCards() { setLayout(new CardLayout()); add("Arc", new ArcCard()); add("Oval", new ShapeTest( new OvalShape() ) ); add("Polygon", new ShapeTest( new PolygonShape() ) ); add("Rect", new ShapeTest( new RectShape() ) ); add("RoundRect", new ShapeTest( new RoundRectShape() ) ); }} // end class GraphicsCardsclass ArcCard extends Panel { public ArcCard() { setLayout(new GridLayout(0, 2)); add(new ArcPanel(true)); add(new ArcPanel(false)); add(new ArcDegreePanel(true)); add(new ArcDegreePanel(false)); }} // end class ArcCardclass ArcDegreePanel extends Panel { boolean filled; public ArcDegreePanel(boolean filled) { this.filled = filled; } void arcSteps(Graphics g, int step, int x, int y, int w, int h, Color c1, Color c2) { int a1 = 0; int a2 = step; int progress = 0; g.setColor(c1); for (; (a1+a2) <= 360; a1 = a1+a2, a2 += 1) { if (g.getColor() == c1) { g.setColor(c2); } else { g.setColor(c1); } if (filled) { g.fillArc(x, y, w, h, a1, a2); } else { g.drawArc(x, y, w, h, a1, a2); } progress = a1+a2; } // end for if (progress != 360) { if (filled) { g.fillArc(x, y, w, h, a1, 360 - progress); } else { g.drawArc(x, y, w, h, a1, 360 - progress); } } // end if } // end arcSteps() public void paint(Graphics g) { Rectangle r = getBounds(); arcSteps(g, 3, 0, 0, r.width, r.height, Color.orange, Color.blue); arcSteps(g, 2, r.width / 4, r.height / 4, r.width / 2, r.height / 2, Color.yellow, Color.green); arcSteps(g, 1, (r.width * 3) / 8, (r.height * 3) / 8, r.width / 4, r.height / 4, Color.magenta, Color.white); } // end paint()} // end class ArcDegreePanelclass ArcPanel extends Panel { boolean filled; public ArcPanel(boolean filled) { this.filled = filled; } public void paint(Graphics g) { Rectangle r = getBounds(); g.setColor(Color.yellow); if (filled) { g.fillArc(0, 0, r.width, r.height, 0, 45); } else { g.drawArc(0, 0, r.width, r.height, 0, 45); } g.setColor(Color.green); if (filled) { g.fillArc(0, 0, r.width, r.height, 90, -45); } else { g.drawArc(0, 0, r.width, r.height, 90, -45); } g.setColor(Color.orange); if (filled) { g.fillArc(0, 0, r.width, r.height, 135, -45); } else { g.drawArc(0, 0, r.width, r.height, 135, -45); } g.setColor(Color.magenta); if (filled) { g.fillArc(0, 0, r.width, r.height, -225, 45); } else { g.drawArc(0, 0, r.width, r.height, -225, 45); } g.setColor(Color.yellow); if (filled) { g.fillArc(0, 0, r.width, r.height, 225, -45); } else { g.drawArc(0, 0, r.width, r.height, 225, -45); } g.setColor(Color.green); if (filled) { g.fillArc(0, 0, r.width, r.height, -135, 45); } else { g.drawArc(0, 0, r.width, r.height, -135, 45); } g.setColor(Color.orange); if (filled) { g.fillArc(0, 0, r.width, r.height, -45, -45); } else { g.drawArc(0, 0, r.width, r.height, -45, -45); } g.setColor(Color.magenta); if (filled) { g.fillArc(0, 0, r.width, r.height, 315, 45); } else { g.drawArc(0, 0, r.width, r.height, 315, 45); } } // end paint()} // end class ArcPanelabstract class Shape{ abstract void draw(Graphics g, int x, int y, int w, int h); abstract void fill(Graphics g, int x, int y, int w, int h);}class RectShape extends Shape{ void draw(Graphics g, int x, int y, int w, int h) { g.drawRect(x, y, w, h); } void fill(Graphics g, int x, int y, int w, int h) { g.fillRect(x, y, w, h); }}class OvalShape extends Shape{ void draw(Graphics g, int x, int y, int w, int h) { g.drawOval(x, y, w, h); } void fill(Graphics g, int x, int y, int w, int h) { g.fillOval(x, y, w, h); }}class RoundRectShape extends Shape{ void draw(Graphics g, int x, int y, int w, int h) { g.drawRoundRect(x, y, w, h, 10, 10); } void fill(Graphics g, int x, int y, int w, int h) { g.fillRoundRect(x, y, w, h, 10, 10); }}class PolygonShape extends Shape{ // class variables Polygon p; Polygon pBase; public PolygonShape() { pBase = new Polygon(); pBase.addPoint(0, 0); pBase.addPoint(10, 0); pBase.addPoint(5, 15); pBase.addPoint(10, 20); pBase.addPoint(5, 20); pBase.addPoint(0, 10); pBase.addPoint(0, 0); } void scalePolygon(float w, float h) { p = new Polygon(); for (int i = 0; i < pBase.npoints; ++i) { p.addPoint( (int) (pBase.xpoints[i] * w), (int) (pBase.ypoints[i] * h) ); } } void draw(Graphics g, int x, int y, int w, int h) { Graphics ng = g.create(); try { ng.translate(x, y); scalePolygon( (float) ( (float) w / (float) 10 ), (float) ( (float) h / (float) 20 ) ); ng.drawPolygon(p); } finally { ng.dispose(); } } void fill(Graphics g, int x, int y, int w, int h) { Graphics ng = g.create(); try { ng.translate(x, y); scalePolygon( (float) ( (float) w / (float) 10 ), (float) ( (float) h / (float) 20 ) ); ng.fillPolygon(p); } finally { ng.dispose(); } }}class ShapeTest extends Panel{ Shape shape; int step; public ShapeTest(Shape shape, int step) { this.shape = shape; this.step = step; } public ShapeTest(Shape shape) { this(shape, 10); } public void paint(Graphics g) { Rectangle bounds = getBounds(); int cx, cy, cw, ch; Color color; for (color=Color.red, cx=bounds.x, cy=bounds.y, cw=bounds.width / 2, ch=bounds.height; cw > 0 && ch > 0; cx+=step, cy += step, cw -= (step * 2), ch -= (step * 2), color=ColorUtils.darker(color, 0.9) ) { g.setColor(color); shape.draw(g, cx, cy, cw, ch); } for (cx=bounds.x + bounds.width / 2, cy=bounds.y, cw=bounds.width / 2, ch=bounds.height; cw > 0 && ch > 0; cx+=step, cy += step, cw -= (step * 2), ch -= (step * 2) ) { if (g.getColor() == Color.red) { g.setColor(Color.blue); } else { g.setColor(Color.red); } shape.fill(g, cx, cy, cw, ch); } // end for } // end paint()} // end class ShapeTestclass ColorUtils { static Color brighter(Color c, double factor) { return new Color( Math.min((int)(c.getRed() *(1/factor)), 255), Math.min((int)(c.getGreen()*(1/factor)), 255), Math.min((int)(c.getBlue() *(1/factor)), 255) ); } static Color darker(Color c, double factor) { return new Color( Math.max((int)(c.getRed() *factor), 0), Math.max((int)(c.getGreen()*factor), 0), Math.max((int)(c.getBlue() *factor), 0) ); }}
1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:43:44:45:46:47:48:49:50:51:52:53:54:55:56:57:58:59:60:61:62:63:64:65:66:67:68:69:70:71:72:73:74:75:76:77:78:79:80:81:82:83:84:85:86:87:88:89:90:91:92:93:94:95:96:97:98:99:100:101:102:103:104:105:106:107:108:109:110:111:112:113:114:115:116:117:118:119:120:121:122:123:124:125:126:127:128:129:130:131:132:133:134:135:136:137:138:139:140:141:142:143:144:145:146:147:148:149:150:151:152:153:154:155:156:157:158:159:160:161:162:163:164:165:166:167:168:169:170:171:172:173:174:175:176:177:178:179:180:181:182:183:184:185:186:187:188:189:190:191:192:193:194:195:196:197:198:199:200:201:202:203:204:205:206:207:208:209:210:211:212:213:214:215:216:217:218:219:220:221:222:223:224:225:226:227:228:229:230:231:232:233:234:235:236:237:238:239:240:241:242:243:244:245:246:247:248:249:250:251:252:253:254:255:256:257:258:259:260:261:262:263:264:265:266:267:268:269:270:271:272:273:274:275:276:277:278:279:280:281:282:283:284:285:286:287:288:289:290:291:292:293:294:295:296:297:298:299:300:301:302:303:304:305:306:307:308:309:310:311:312:313:314:315:316:317:318:319:320:321:322:323:324:325:326:327:328:329:330:331:332:333:334:335:336:337:338:339:340:341:342:343:344:345:346:347:348:349:350:351:352:353:354:355:356:357:358:359:360:361:362:363:364:365:366:367:368:369:370:371:372:373:374:375:376:377:378:379:380:381:382:383:384:385:386:387:388:389:390:391:392:393:394:395:396:397:398:399:400:401:402:403:404:405:406:407:408:409:410:411:412:413:414:415:416:417:418:419:420:421:422:423:424:425:426:427:428:429:430:431:432:433:434:435:436:437:438:439:440:441:442:443:444:445:446:447:448:449:450:451:452:453:454:455:456:457:458:459:460:461:462:463:464:465:466:467:468:469:470:471:472:473:474:475:476:477:478:479:480:481:482:483:484:485:486:487:488:489:490:491:492:
Thank pramodkrjsr, I understand now.. Actually, those demo examples are in purpose to demonstrate
the example on website and Appletviewer only. Not for C: shell line command
Actually, I want it work at command line at C:, so I modify the code as follows
and name the file Clock1 from Clock.java. It passed the complier . But the Java wondows
doesn't came out and no any result I could seen. The issue is at define Class public main() { }.
But I found only GraphicsTest.java in demo examples also works at all method from command line(java GraphicsTest), Appletviewer, webpage (note reference link:
http://java.sun.com/applets/jdk/1.4/demo/applets/GraphicsTest/example1.html & http://java.sun.com/applets/jdk/1.4/index.html)
If possible, you could try it in three ways and then try the clock one and you's will know what I mean
1) Java GraphicsTest
2) Appletviewer GraphicsTest
3) GarphicsTest.html in IE
Br
Duncan
class Clock1 {public static void main (String[] argv) { class Clock2 extends Applet implements Runnable { private volatile Thread timer; // The thread that displays clock private int lastxs, lastys, lastxm, lastym, lastxh, lastyh; // Dimensions used to draw hands private SimpleDateFormat formatter; // Formats the date displayed private String lastdate; // String to hold date displayed private Font clockFaceFont; // Font for number display on clock private Date currentDate; // Used to get date to display private Color handColor; // Color of main hands and dial private Color numberColor; // Color of second hand and numbers private int xcenter = 80, ycenter = 55; // Center position public void init() { int x,y; lastxs = lastys = lastxm = lastym = lastxh = lastyh = 0; formatter = new SimpleDateFormat ("EEE MMM dd hh:mm:ss yyyy", Locale.getDefault()); currentDate = new Date(); lastdate = formatter.format(currentDate); clockFaceFont = new Font("Serif", Font.PLAIN, 14); handColor = Color.blue; numberColor = Color.darkGray; try { setBackground(new Color(Integer.parseInt(getParameter("bgcolor"), 16))); } catch (NullPointerException e) { } catch (NumberFormatException e) { } try { handColor = new Color(Integer.parseInt(getParameter("fgcolor1"), 16)); } catch (NullPointerException e) { } catch (NumberFormatException e) { } try {
1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:
Thank pramodkrjsr, I understand now.. Actually, those demo examples are in purpose to demonstrate
the example on website and Appletviewer only. Not for C: shell line command
Actually, I want it work at command line at C:, so I modify the code as follows
and name the file Clock1 from Clock.java. It passed the complier . But the Java wondows
doesn't came out and no any result I could seen. The issue is at define Class public main() { }.
But I found only GraphicsTest.java in demo examples also works at all method from command line(java GraphicsTest), Appletviewer, webpage (note reference link:
http://java.sun.com/applets/jdk/1.4/demo/applets/GraphicsTest/example1.html & http://java.sun.com/applets/jdk/1.4/index.html)
If possible, you could try it in three ways and then try the clock one and you's will know what I mean
1) Java GraphicsTest
2) Appletviewer GraphicsTest
3) GarphicsTest.html in IE
Br
Duncan
class Clock1 {public static void main (String[] argv) { class Clock2 extends Applet implements Runnable { private volatile Thread timer; // The thread that displays clock private int lastxs, lastys, lastxm, lastym, lastxh, lastyh; // Dimensions used to draw hands private SimpleDateFormat formatter; // Formats the date displayed private String lastdate; // String to hold date displayed private Font clockFaceFont; // Font for number display on clock private Date currentDate; // Used to get date to display private Color handColor; // Color of main hands and dial private Color numberColor; // Color of second hand and numbers private int xcenter = 80, ycenter = 55; // Center position public void init() { int x,y; lastxs = lastys = lastxm = lastym = lastxh = lastyh = 0; formatter = new SimpleDateFormat ("EEE MMM dd hh:mm:ss yyyy", Locale.getDefault()); currentDate = new Date(); lastdate = formatter.format(currentDate); clockFaceFont = new Font("Serif", Font.PLAIN, 14); handColor = Color.blue; numberColor = Color.darkGray; try { setBackground(new Color(Integer.parseInt(getParameter("bgcolor"), 16))); } catch (NullPointerException e) { } catch (NumberFormatException e) { } try { handColor = new Color(Integer.parseInt(getParameter("fgcolor1"), 16)); } catch (NullPointerException e) { } catch (NumberFormatException e) { } try {
1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:
Thank pramodkrjsr, I understand now.. Actually, those demo examples are in purpose to demonstrate
the example on website and Appletviewer only. Not for C: shell line command
Actually, I want it work at command line at C:, so I modify the code as follows
and name the file Clock1 from Clock.java. It passed the complier . But the Java wondows
doesn't came out and no any result I could seen. The issue is at define Class public main() { }.
But I found only GraphicsTest.java in demo examples also works at all method from command line(java GraphicsTest), Appletviewer, webpage (note reference link:
http://java.sun.com/applets/jdk/1.4/demo/applets/GraphicsTest/example1.html & http://java.sun.com/applets/jdk/1.4/index.html)
If possible, you could try it in three ways and then try the clock one and you's will know what I mean
1) Java GraphicsTest
2) Appletviewer GraphicsTest
3) GarphicsTest.html in IE
Br
Duncan
class Clock1 {public static void main (String[] argv) { class Clock2 extends Applet implements Runnable { private volatile Thread timer; // The thread that displays clock private int lastxs, lastys, lastxm, lastym, lastxh, lastyh; // Dimensions used to draw hands private SimpleDateFormat formatter; // Formats the date displayed private String lastdate; // String to hold date displayed private Font clockFaceFont; // Font for number display on clock private Date currentDate; // Used to get date to display private Color handColor; // Color of main hands and dial private Color numberColor; // Color of second hand and numbers private int xcenter = 80, ycenter = 55; // Center position public void init() { int x,y; lastxs = lastys = lastxm = lastym = lastxh = lastyh = 0; formatter = new SimpleDateFormat ("EEE MMM dd hh:mm:ss yyyy", Locale.getDefault()); currentDate = new Date(); lastdate = formatter.format(currentDate); clockFaceFont = new Font("Serif", Font.PLAIN, 14); handColor = Color.blue; numberColor = Color.darkGray; try { setBackground(new Color(Integer.parseInt(getParameter("bgcolor"), 16))); } catch (NullPointerException e) { } catch (NumberFormatException e) { } try { handColor = new Color(Integer.parseInt(getParameter("fgcolor1"), 16)); } catch (NullPointerException e) { } catch (NumberFormatException e) { } try {
1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:
Thank pramodkrjsr, I understand now.. Actually, those demo examples are in purpose to demonstrate
the example on website and Appletviewer only. Not for C: shell line command
Actually, I want it work at command line at C:, so I modify the code as follows
and name the file Clock1 from Clock.java. It passed the complier . But the Java wondows
doesn't came out and no any result I could seen. The issue is at define Class public main() { }.
But I found only GraphicsTest.java in demo examples also works at all method from command line(java GraphicsTest), Appletviewer, webpage (note reference link:
http://java.sun.com/applets/jdk/1.4/demo/applets/GraphicsTest/example1.html & http://java.sun.com/applets/jdk/1.4/index.html)
If possible, you could try it in three ways and then try the clock one and you's will know what I mean
1) Java GraphicsTest
2) Appletviewer GraphicsTest
3) GarphicsTest.html in IE
Br
Duncan
class Clock1 {public static void main (String[] argv) { class Clock2 extends Applet implements Runnable { private volatile Thread timer; // The thread that displays clock private int lastxs, lastys, lastxm, lastym, lastxh, lastyh; // Dimensions used to draw hands private SimpleDateFormat formatter; // Formats the date displayed private String lastdate; // String to hold date displayed private Font clockFaceFont; // Font for number display on clock private Date currentDate; // Used to get date to display private Color handColor; // Color of main hands and dial private Color numberColor; // Color of second hand and numbers private int xcenter = 80, ycenter = 55; // Center position public void init() { int x,y; lastxs = lastys = lastxm = lastym = lastxh = lastyh = 0; formatter = new SimpleDateFormat ("EEE MMM dd hh:mm:ss yyyy", Locale.getDefault()); currentDate = new Date(); lastdate = formatter.format(currentDate); clockFaceFont = new Font("Serif", Font.PLAIN, 14); handColor = Color.blue; numberColor = Color.darkGray; try { setBackground(new Color(Integer.parseInt(getParameter("bgcolor"), 16))); } catch (NullPointerException e) { } catch (NumberFormatException e) { } try { handColor = new Color(Integer.parseInt(getParameter("fgcolor1"), 16)); } catch (NullPointerException e) { } catch (NumberFormatException e) { } try {
1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:
Thank pramodkrjsr, I understand now.. Actually, those demo examples are in purpose to demonstrate
the example on website and Appletviewer only. Not for C: shell line command
Actually, I want it work at command line at C:, so I modify the code as follows
and name the file Clock1 from Clock.java. It passed the complier . But the Java wondows
doesn't came out and no any result I could seen. The issue is at define Class public main() { }.
But I found only GraphicsTest.java in demo examples also works at all method from command line(java GraphicsTest), Appletviewer, webpage (note reference link:
http://java.sun.com/applets/jdk/1.4/demo/applets/GraphicsTest/example1.html & http://java.sun.com/applets/jdk/1.4/index.html)
If possible, you could try it in three ways and then try the clock one and you's will know what I mean
1) Java GraphicsTest
2) Appletviewer GraphicsTest
3) GarphicsTest.html in IE
Br
Duncan
class Clock1 {public static void main (String[] argv) { class Clock2 extends Applet implements Runnable { private volatile Thread timer; // The thread that displays clock private int lastxs, lastys, lastxm, lastym, lastxh, lastyh; // Dimensions used to draw hands private SimpleDateFormat formatter; // Formats the date displayed private String lastdate; // String to hold date displayed private Font clockFaceFont; // Font for number display on clock private Date currentDate; // Used to get date to display private Color handColor; // Color of main hands and dial private Color numberColor; // Color of second hand and numbers private int xcenter = 80, ycenter = 55; // Center position public void init() { int x,y; lastxs = lastys = lastxm = lastym = lastxh = lastyh = 0; formatter = new SimpleDateFormat ("EEE MMM dd hh:mm:ss yyyy", Locale.getDefault()); currentDate = new Date(); lastdate = formatter.format(currentDate); clockFaceFont = new Font("Serif", Font.PLAIN, 14); handColor = Color.blue; numberColor = Color.darkGray; try { setBackground(new Color(Integer.parseInt(getParameter("bgcolor"), 16))); } catch (NullPointerException e) { } catch (NumberFormatException e) { } try { handColor = new Color(Integer.parseInt(getParameter("fgcolor1"), 16)); } catch (NullPointerException e) { } catch (NumberFormatException e) { } try {
1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:
Thank pramodkrjsr, I understand now.. Actually, those demo examples are in purpose to demonstrate
the example on website and Appletviewer only. Not for C: shell line command
Actually, I want it work at command line at C:, so I modify the code as follows
and name the file Clock1 from Clock.java. It passed the complier . But the Java wondows
doesn't came out and no any result I could seen. The issue is at define Class public main() { }.
But I found only GraphicsTest.java in demo examples also works at all method from command line(java GraphicsTest), Appletviewer, webpage (note reference link:
http://java.sun.com/applets/jdk/1.4/demo/applets/GraphicsTest/example1.html & http://java.sun.com/applets/jdk/1.4/index.html)
If possible, you could try it in three ways and then try the clock one and you's will know what I mean
1) Java GraphicsTest
2) Appletviewer GraphicsTest
3) GarphicsTest.html in IE
Br
Duncan
class Clock1 {public static void main (String[] argv) { class Clock2 extends Applet implements Runnable { private volatile Thread timer; // The thread that displays clock private int lastxs, lastys, lastxm, lastym, lastxh, lastyh; // Dimensions used to draw hands private SimpleDateFormat formatter; // Formats the date displayed private String lastdate; // String to hold date displayed private Font clockFaceFont; // Font for number display on clock private Date currentDate; // Used to get date to display private Color handColor; // Color of main hands and dial private Color numberColor; // Color of second hand and numbers private int xcenter = 80, ycenter = 55; // Center position public void init() { int x,y; lastxs = lastys = lastxm = lastym = lastxh = lastyh = 0; formatter = new SimpleDateFormat ("EEE MMM dd hh:mm:ss yyyy", Locale.getDefault()); currentDate = new Date(); lastdate = formatter.format(currentDate); clockFaceFont = new Font("Serif", Font.PLAIN, 14); handColor = Color.blue; numberColor = Color.darkGray; try { setBackground(new Color(Integer.parseInt(getParameter("bgcolor"), 16))); } catch (NullPointerException e) { } catch (NumberFormatException e) { } try { handColor = new Color(Integer.parseInt(getParameter("fgcolor1"), 16)); } catch (NullPointerException e) { } catch (NumberFormatException e) { } try {
1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39: