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

Unable to add the Jpanel dynamically inside a single frame.  RSS feed

 
sumanth kavikondala
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
H Friends,
I am building a GUI application which consists of two panels "panel" and "panel1". "panel1" have a button "addTimer" when clicked it should add the "panel" to the frame if i gain click the button it should again add the "panel" without overlapping the previous "panel" rather it should be created below the previous "panel". If i click on the button "addTimer" n times it should add the panel n times. Along with this the frame size has to dynamically change depending on the number of panels produced. Below is the code i tried my level best to satisfy the above conditions.

Please give me your valuable suggestions. Thank you in advance.

 
Campbell Ritchie
Marshal
Posts: 55681
162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Don't add things dynamically. It looks very strange if the display changes suddenly like that. Consider a dialogue instead.
 
sumanth kavikondala
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to add dynamically because this is the project given to me in my school. Please suggest me.
 
Piet Souris
Rancher
Posts: 1979
67
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Sumanth,

here is a small program that just adds a new panel when you click on a button.
It doesn't use a GridLayout, consider it as an example that you can use to
get an idea how to achieve your goal.

Greetz,
Piet
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!