This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
After selecting mode my program displays a frame (extends JFrame) with the menu bar. When user selects any option (eg Search by Name). control in Program goes to another file(without extends JFrame) that has different gui components(including JPanel(s) but not JFrame) and other relevant code. Now I remove any previous existing panel and display this new panel(s) inthe old frame with same menu bar. ofcourse used Singelton for this.
I read in some forums on net that singelton in GUI does not work good in some operating systems when have many clients. Another says Singelton pattern is anti pattern.
Can you, my fellows, please give your opinion about this or any better design.
singleton is nothing else by a unique object instance. Each time you will launch a new Client the VM will create a new instance for the new launch, this not going to be shared between the two clients. As i understood you have a main frame and you remove and place panels according to the user's action. Speaking for design point of view it would have been better if you have used a Cardlayout and according to the user's action display the apropriate card.
Singleton will behave just fine like other clasess as long as you manipulate its content thread safe, all operations done on Swing code to be performend by the event dispatch thread.
I agree with Nicolas on this one: if you decide to switch panels in your main window, you should use the CardLayout, because that layout is designed to do what you want. If you use your own custom system (singleton pattern or not), it conflicts with this principle (from instructions.html):
Use of functionality provided by the core Java classes will be preferred to your own implementation of that functionality, unless there is a specific advantage to providing your own implementation.