// using Objects : Frame, TextField, Button --- by tsaiwn@csie.nctu.edu.tw // Encapsulation and Information Hiding: // .. 不必知道 Frame, Button 等 Object 如何做的, 也可以拿來用 // .. But we must find out what methods (functions) they offer ! public class MyObject { public static void main(String[ ] args) { java.awt.Frame f = new java.awt.Frame("Test using Object of classes"); java.awt.TextField t = new java.awt.TextField ("天下為公", 20); t.setFont(new java.awt.Font("標楷體", 2, 64)); java.awt.Button b = new java.awt.Button("Press me"); b.setForeground(java.awt.Color.red); b.setFont(new java.awt.Font("Ludica Console", 2, 32)); java.awt.Button b2 = new java.awt.Button("another Button"); f.add(b2, "West"); f.add(t,"North"); f.add(b, "South"); f.setSize(380,380); f.show(); // linger a while and then quit try{ Thread.sleep(5688); } catch(Exception e){;} System.exit(0); } // main // that's it :-) } /*** *** *** will show a Window like this Test using Object of classes 天下為公 another button press me *** *** ***/