• Post Reply Bookmark Topic Watch Topic
  • New Topic

Display JCheckbox and JTextfields.  RSS feed

 
Andrew Geroge Alexander
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • 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.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Rob Spoor
Sheriff
Posts: 20896
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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: 20896
81
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!