This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Information on Controller Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Information on Controller" Watch "Information on Controller" New topic
Author

Information on Controller

Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
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.

Thank you,
Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
Am I posting this question in the wrong forum?
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
For an example of MVC, see reply 13 on this thread. To access the images now, replace the prefix string (in the static block in ImageView) with this

[ December 01, 2004: Message edited by: Craig Wood ]
Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
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)

Dynamic libraries:
0x00400000 - 0x00406000 C:\j2sdk1.4.2_04\bin\java.exe
0x7C900000 - 0x7C9B0000 C:\WINDOWS\system32\ntdll.dll
0x7C800000 - 0x7C8F4000 C:\WINDOWS\system32\kernel32.dll
0x77DD0000 - 0x77E6B000 C:\WINDOWS\system32\ADVAPI32.dll
0x77E70000 - 0x77F01000 C:\WINDOWS\system32\RPCRT4.dll
0x77C10000 - 0x77C68000 C:\WINDOWS\system32\MSVCRT.dll
0x08000000 - 0x08138000 C:\j2sdk1.4.2_04\jre\bin\client\jvm.dll
0x77D40000 - 0x77DD0000 C:\WINDOWS\system32\USER32.dll
0x77F10000 - 0x77F56000 C:\WINDOWS\system32\GDI32.dll
0x76B40000 - 0x76B6D000 C:\WINDOWS\system32\WINMM.dll
0x10000000 - 0x10007000 C:\j2sdk1.4.2_04\jre\bin\hpi.dll
0x00390000 - 0x0039E000 C:\j2sdk1.4.2_04\jre\bin\verify.dll
0x003B0000 - 0x003C9000 C:\j2sdk1.4.2_04\jre\bin\java.dll
0x003D0000 - 0x003DD000 C:\j2sdk1.4.2_04\jre\bin\zip.dll
0x02C60000 - 0x02D6F000 C:\j2sdk1.4.2_04\jre\bin\awt.dll
0x73000000 - 0x73026000 C:\WINDOWS\system32\WINSPOOL.DRV
0x76390000 - 0x763AD000 C:\WINDOWS\system32\IMM32.dll
0x774E0000 - 0x7761C000 C:\WINDOWS\system32\ole32.dll
0x5AD70000 - 0x5ADA8000 C:\WINDOWS\system32\uxtheme.dll
0x02DD0000 - 0x02E20000 C:\j2sdk1.4.2_04\jre\bin\fontmanager.dll
0x73760000 - 0x737A9000 C:\WINDOWS\system32\ddraw.dll
0x73BC0000 - 0x73BC6000 C:\WINDOWS\system32\DCIMAN32.dll
0x73940000 - 0x73A10000 C:\WINDOWS\system32\D3DIM700.DLL
0x03830000 - 0x03853000 C:\j2sdk1.4.2_04\jre\bin\cmm.dll
0x03960000 - 0x0397E000 C:\j2sdk1.4.2_04\jre\bin\jpeg.dll
0x03980000 - 0x0398F000 C:\j2sdk1.4.2_04\jre\bin\net.dll
0x71AB0000 - 0x71AC7000 C:\WINDOWS\system32\WS2_32.dll
0x71AA0000 - 0x71AA8000 C:\WINDOWS\system32\WS2HELP.dll
0x71A50000 - 0x71A8F000 C:\WINDOWS\System32\mswsock.dll
0x76F20000 - 0x76F47000 C:\WINDOWS\system32\DNSAPI.dll
0x76D60000 - 0x76D79000 C:\WINDOWS\system32\iphlpapi.dll
0x76FB0000 - 0x76FB8000 C:\WINDOWS\System32\winrnr.dll
0x76F60000 - 0x76F8C000 C:\WINDOWS\system32\WLDAP32.dll
0x03AF0000 - 0x03B18000 C:\WINDOWS\system32\YPCLSP.dll
0x771B0000 - 0x77256000 C:\WINDOWS\system32\WININET.dll
0x77F60000 - 0x77FD6000 C:\WINDOWS\system32\SHLWAPI.dll
0x77A80000 - 0x77B14000 C:\WINDOWS\system32\CRYPT32.dll
0x77B20000 - 0x77B32000 C:\WINDOWS\system32\MSASN1.dll
0x77120000 - 0x771AC000 C:\WINDOWS\system32\OLEAUT32.dll
0x773D0000 - 0x774D2000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll
0x662B0000 - 0x66308000 C:\WINDOWS\system32\hnetcfg.dll
0x71A90000 - 0x71A98000 C:\WINDOWS\System32\wshtcpip.dll
0x77FE0000 - 0x77FF1000 C:\WINDOWS\system32\Secur32.dll
0x76FD0000 - 0x7704F000 C:\WINDOWS\system32\CLBCATQ.DLL
0x77050000 - 0x77115000 C:\WINDOWS\system32\COMRes.dll
0x77C00000 - 0x77C08000 C:\WINDOWS\system32\VERSION.dll
0x20000000 - 0x202C5000 C:\WINDOWS\system32\xpsp2res.dll
0x76FC0000 - 0x76FC6000 C:\WINDOWS\system32\rasadhlp.dll
0x76C90000 - 0x76CB8000 C:\WINDOWS\system32\imagehlp.dll
0x59A60000 - 0x59B01000 C:\WINDOWS\system32\DBGHELP.dll
0x76BF0000 - 0x76BFB000 C:\WINDOWS\system32\PSAPI.DLL

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.
#

Any idea why I'm getting this error?
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
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.
Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
Thanks Craig, I'll see what I can figure out.
 
 
subject: Information on Controller