We need to transfer multiple data objects like String
, int
, float
, etc from one GUI (JFrame
, JInternalFrame
, etc) to another GUI. We can tranfer them by using parameters in the constructors or share the data through a singleton class.
However, my question is how to pack multiple data objects into a single object and pass them as a single parameter between GUIs in Java Swing? In Android, we can do that using Bundle objects. Similarly, is there any such object in Java/Swing which can be used?
You have numerous options, however the two most likely to meet your needs would either be a custom Object
or a Map
. A custom object would have fields for each piece of information you need to transfer. See here for more information.