This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Making GUI application's design extensible  RSS feed

 
Alok Kmishra
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have to create a Swing application for which i haved a set of requirements as,
1. there will be two JPanels ,left and right, on the main JFrame , left frame would contain a JTextField and a submit JButton ,user can enter values 1,2,3 ,in the JTextField and presses the JButton
a. if user enters 1, a JTextField will be shown on right JPanel
b. if user enters 2, a JTextField and a JRadioButton will be shown on right JPanel
c. if user enters 3, a JTextField and a JComboBox will be shown on right JPanel
so i have done that but when my boss sees the code behind this application he told me to make it more extensible i.e. if there is going to be an aditional requirement for values 4 or 5 or 6 and so on , then i have to make minimal changes in my code or no change in my code and it should work . how this can be done ? is it possible make such software design ?



please suggest what wrong am i doing here in this code which in not considered to be an extensible design ?
 
Campbell Ritchie
Sheriff
Posts: 55333
157
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why on earth do you want such a display? If you want things to appear and disappear consider a card layout. Or tabbed panes.

Even without that, I would start by giving all the fields meaningful names. Names like jl1 do nothing but confuse.
I would get rid of that single actionPerformed method which is a maintenance problem.
Why have you got that serial version ID?
 
Alok Kmishra
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Why on earth do you want such a display? If you want things to appear and disappear consider a card layout. Or tabbed panes.

Even without that, I would start by giving all the fields meaningful names. Names like jl1 do nothing but confuse.
I would get rid of that single actionPerformed method which is a maintenance problem.
Why have you got that serial version ID?


yes i should have taken care of the Layout Manger and naming conventions but what do you mean by "I would get rid of that single actionPerformed method which is a maintenance problem." ? i didnt get this .
 
Campbell Ritchie
Sheriff
Posts: 55333
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have an action listener object (or a λ) for each of the actions required. Not one method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!