I am writing my first simple application and couldn't find the proper way to declare bean, that shouldn't be instantiated on app startup. My case is:
I have a main window, where is button that opens another window - for now it's ok.
I want another window (where the user will fill the data and send some to main window) opening from it. When I declare bean with another window both windows appears on startup.
Shouldn't I declare bean for that window (so for what is that XML file? Only for main frame?)
Should I create another XML file?
Should I set some property for such bean?
In Spring, beans are not instantiated by default until you request them from the bean factory. Also, I think you have the terms "define" and "create" confused. We use the term "create" and "instantiate" to mean essentially the same thing - instantiate is just the more formal term.
Also, from the sound of it, you want your app to display a (probably modal) dialog, not merely "open a window". A dialog is a special type of window, generally used for data entry or user approval as a pop-up object that, once its task is done is dismissed, leaving the primary application window(s).
Most commonly when I do that sort of thing, I create a GUI Model object (bean), which can be managed by the Spring bean factory. The data entry dialog(s) - sometimes there will be a whole series of them, like with a "wizard" - then display such data as was pre-initialized in the bean and accept changes made in the dialog to the bean. There may even be a shadow bean behind the data-entry Model if you implement a "revert" function to undo all changes made in the dialog.
Once the GUI Model bean is created, I create a View and link it via Controllers to the Mode, which gives me the classic Model/View/Controller (MVC) construct.
To dismiss the process, there's usually an OK and Cancel buttons. The OK button dismisses the dialog window and copies data from the Model bean into the main working storage of the app - sometimes this involves writing that data out to a persistent storage (file or database, for example). The Cancel button likewise dismisses the dialog window, but it then discards the Model bean without bothering to copy data from it first.
Being persecuted doesn't in any way prove your righteousness or your beliefs. Many people get persecuted because they are repugnant or annoying. Or just because they can be.
Wait for it ... wait .... wait .... NOW! Pafiffle! A perfect tiny ad!