Slowly find the Feeling ~ ~
PackageSwingGui.sky.com;Importjavax.swing.*;Importjava.awt.*;Importjava.awt.event.*; Public classSimpleguiImplementsActionListener {JFrame frame; JLabel label; intX =70; inty = 70; Public Static voidmain (String [] args) {Simplegui GUI=NewSimplegui (); Gui.go (); } Public voidGo () {frame=NewJFrame (); Frame.setdefaultcloseoperation (Jframe.exit_on_close); JButton Labelbutton=NewJButton ("Change Label"); Labelbutton.addactionlistener (NewLabellistener ()); JButton Colorbutton=NewJButton ("Change Circle"); Colorbutton.addactionlistener (NewColorlistener ()); Label=NewJLabel ("I am a label"); Mydrawpanel Drawpanel=NewMydrawpanel (); Frame.getcontentpane (). Add (Drawpanel); Frame.getcontentpane (). Add (Borderlayout.south, Colorbutton); Frame.getcontentpane (). Add (Borderlayout.center, Drawpanel); Frame.getcontentpane (). Add (Borderlayout.east, Labelbutton); Frame.getcontentpane (). Add (borderlayout.west, label); Frame.setsize (800, 500); Frame.setvisible (true); for(inti = 0; I < 130; i++) {x++; Y++; Drawpanel.repaint (); Try{Thread.Sleep (20); } Catch(Exception ex) {}}} @Override Public voidactionperformed (ActionEvent event) {JButton button=(JButton) Event.getsource (); Button.settext ("I ' v been clicked!.."); Button.setbackground (Color.Blue); } classLabellistenerImplementsActionListener { Public voidactionperformed (ActionEvent event) {Label.settext ("Ouch"); } } classColorlistenerImplementsActionListener { Public voidactionperformed (ActionEvent event) {frame.repaint (); } } classMydrawpanelextendsJPanel { Public voidpaintcomponent (Graphics g) {G.setcolor (color.white); G.fillrect (0, 0, This. GetWidth (), This. GetHeight ()); G.setcolor (Color.green); G.filloval (x, Y,40, 40); } }}
Java Simple Swing and AWT