This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

handling panels  RSS feed

 
Rashid Darvesh
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I got a swing project which was developed by my ex-colleague. I looked at it source code and basicallly there are three panels.
LoginPanel
ReportRequestPanel
ReportResultPanel
The way the project was implemented is they have one Maincontoller class and the classes (Loginpanel, ReportRequestPanel, ReportResultPanel) are implemented as Inner classes extending the JPanel. so they can plug in and out the component when they want. So the user is first presented with the loginscreen and upon success it takes the user to the Report request and user selects certain criteria and teh result screen is displayed. Is this the correct way to do it by writing inner classes which extends Jpanel or writing and independent class for all the three panel. hence, for each new screen i have to add inner class. is this the ideal way to do it.
Please lemme know
Thanks
 
Mike Southgate
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally, I wouldn't do it that way. I generally create my dialogs and/or panels as completely separate classes. That way you can add as many as you need without bloating your main class. It's pretty easy to pull the inner classes out if you want to.

ms
 
Rashid Darvesh
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mike.
I removed those inner classes and made independent class.
I want to know how to share the same data throught out multiple panels. As of now i have a report object which consists report criteria and report output. The report critria is populated by the report request screen and after fetching the data the report output is used to display data in the report result panel. I made the report object as static in the maincontroller so that all the panels can access the data. is it the best practice

Thanks
RASHID
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!