• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Display JCheckbox and JTextfields.

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ranchers,

I have a small problem/need. I am planning to display a JFrame (on a click of a button) that will; based on the number of files in a folder display checkboxes and text fields.

for example, Say in Folder
C:/Data --> No. of files are 3, then there should be 3 checkboxes and 3 textfields.
C:/SampData --> No. of files are 5, then 5 CheckBoxes and 5 text fields.

Is there a way to get this working? Any help will be greatly appreciated.

P.S. I am working on Java IDE.
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, yes, it's certainly possible. What have you done so far, and which bit are you having problems with?
 
Andrew Geroge Alexander
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All I have done is 'I TRIED TO' create a panel with the checkbox and after initialising the form called the method



This one does set one checkbox on the panel. I tried calling tnis method 3 times (manually) but it is not displaying 3, just one.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then don't use a BorderLayout. That only allows one component as its center component, so next time you add one it will remove the existing one.
 
Andrew Geroge Alexander
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the tip, Rob. I tried the FlowLayout. It works, but the display is disoriented. I mean the button that i need at the bottom is up and they are arranged in a continous row.. I would like it to come one after another..
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That just means that (only) a FlowLayout is not the right choice. You should experiment a bit, and keep in mind that it's not bad if you create some JPanels to put inside the current JPanel. That allows you to use a JPanel with a (for instance) FlowLayout within a JPanel with a BorderLayout.
 
The knights of nee want a shrubbery. And a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic