Hello everyone, I'm fairly new to Swing, only coded 2 UIs so far (what a pain it was). Can someone show me a "small" code example of how a Controller interacts with the View? I'm trying to implement the MVC into my project. I think I have a pretty good idea on how the Model works, in that the Controller would simply call a method on the Model passing any parms. So, how is the View interacting with the Controller, passing events and data? Should there be a controller for every window and should the controller control every object within the window?
Any additional information you can provide is appreciated.
Hi Craig, Thanks for replying back. I made the modification as you requested and then ran the App and received the following error:
An unexpected exception has been detected in native code outside the VM. Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x3AF9558 Function=[Unknown.] Library=C:\WINDOWS\system32\YPCLSP.dll
NOTE: We are unable to locate the function name symbol for the error just occurred. Please refer to release documentation for possible reason and solutions.
Current Java thread: at java.net.PlainSocketImpl.socketClose0(Native Method) at java.net.PlainSocketImpl.socketPreClose(PlainSocketImpl.java:610) at java.net.PlainSocketImpl.close(PlainSocketImpl.java:454) - locked <0x105382b0> (a java.lang.Object) at java.net.Socket.close(Socket.java:1247) - locked <0x10538218> (a java.lang.Object) - locked <0x10532f88> (a java.net.Socket) at sun.net.www.http.HttpClient.closeServer(HttpClient.java:939) at sun.net.www.http.KeepAliveCache.run(KeepAliveCache.java:177) - locked <0x1053cc08> (a sun.net.www.http.ClientVector) - locked <0x1051c2c0> (a sun.net.www.http.KeepAliveCache) at java.lang.Thread.run(Thread.java:534)
Heap at VM Abort: Heap def new generation total 576K, used 356K [0x10010000, 0x100b0000, 0x104f0000) eden space 512K, 57% used [0x10010000, 0x100591c0, 0x10090000) from space 64K, 100% used [0x10090000, 0x100a0000, 0x100a0000) to space 64K, 0% used [0x100a0000, 0x100a0000, 0x100b0000) tenured generation total 1408K, used 517K [0x104f0000, 0x10650000, 0x14010000) the space 1408K, 36% used [0x104f0000, 0x10571728, 0x10571800, 0x10650000) compacting perm gen total 4352K, used 4331K [0x14010000, 0x14450000, 0x18010000) the space 4352K, 99% used [0x14010000, 0x1444aef0, 0x1444b000, 0x14450000)
Local Time = Sun Dec 05 19:04:59 2004 Elapsed Time = 12 # # The exception above was detected in native code outside the VM # # Java VM: Java HotSpot(TM) Client VM (1.4.2_04-b05 mixed mode) # # An error report file has been saved as hs_err_pid908.log. # Please refer to the file for further information. #
Ouch. That doesn't look like fun. This has come up with certain video cards in the recent past. You might try searching the forums at Sun; I remember seeing an informative thread a while back. Have you had similar difficulties with other image and/or animation apps? You can find some in this forum and at Sun, especially their Java2D forum.