简体   繁体   中英

Returning A Value To a Swing Class from another Swing Class

Some background on myself. Former AS/400 guy, recently downsized and unemployed. Taking this opportunity to learn java. I'm fairly new to Java and Netbeans. Since I'm unemployed and not in an organization with 'experts', I'm trying to find resources for help. I'm in ATLanta so I've joined www.ajug.org in hopes of networking with folks to find resources. I've also applied for some 'Obama Bucks' in order to take some classes. Until then I was hoping to ask you "Good Folks" for some help!

I've developed the security structure and a dynamic menu for a SWING application that uses MySQL. I've developed lots of SWING apps and compiled the classes that perform TABLE maintenance (Insert/Update/Delete) on the TABLES my application will use. NOW, I'm getting into the 'nitty-gritty' of the application. I'm continuing to stumble over 'pretty simple stuff' that I believe a 'SWING Application Architect' or one of you Netbeans/SWING experts could readily answer.

Concerning Netbeans and Returning a value from a SWING class.
Netbeans creates two or more .java files in my projects.
Example: desktopapplication project contains - DesktopApplicationApp.java and - DesktopApplicationView.java Normally, DesktopApplicationApp.java launches() itself and then in startup() it does a show(new DesktopApplicationView(this)). I have several "look up" TABLES tables and want to create separate classes that allow the user to search through the TABLE a return a row. (This is OOP, right!?) So if I have an application (DesktopApplicationApp and DesktopApplicationView) and I want use another CLASS SelectValueApp to search a database and return a key value to DesktopApplicationView.

My "Menu Program" just does an execCMD() to run the Classes in my application.

For "CALLING" SelectValueApp from DesktopApplicationView I know I should use a constructor and create an instance of SelectValueApp .... but what method do I use to "retrieve the key" from the class?

Can I just Launch() the SelectValueView from DesktopApplicationView? I read, "Using the Swing Application Framework(JSR296)" and I'm still not clear on how to do this. I'm thinking that when SelectValueApp completes the EXIT() it will cause a shutdown of the JVM (And kill DesktopApplicationView).

I could include the functionality of SelectValueView in DesktopApplicationView but this program is already HUGE!

So I've a bunch of questions. 1) How do I accomplish this? (please). Also, I've referenced these posts and they are "very Close" to what I need to know.
questions/1091389/how-to-transfer-objects-from-jframe-to-another-jframe questions/573317/java-swing-close-window-without-exiting-app questions/573378/managing-parent-frame-from-child-frame-on-java-swing

2) Is it a limitation of "SingleFrameApplication"? (Trying to open another frame to return the value) 3) Do I have to put all the functionality in the MyApplicationView? 4) Or does the code that Netbeans generates just make this tough and there is a simple, elegant way to accomplish this?

ALSO, I'll create a Short, Self Contained, Correct (Compilable), Example (SSCCE) and update this post

Thanking you in advance,

Current Java Newbie / Future Java CSD and Java Heavyweight,

I'm not sure that many projects use the Swing Application Framework. It's way immature IMHO

and companies already have their "own" frameworks or solutions for speed up development or

deal with common annoyances.

I would suggest to look at the JSR296 documentation in details.

By the way, you don't have to tell us your whole background, people will help you if they can/want.

The Swing Application Framework is dead in the water -- from what I hear, most of the developers have been moved over to JavaFX.

As for your general design problem -- is there a reason that the different pieces need to be separate applications? My instinct is that you don't need to do that, and that therefore you don't need a socket listener, you just need callbacks so the classes that need to talk to each other can do so in an event-driven way.

Maybe a better choice is Spring Rich Client?

Or even one of this list: http://karussell.wordpress.com/2009/10/08/java-application-frameworks-not-only-client-side/

??

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM