• Post Reply Bookmark Topic Watch Topic
  • New Topic

Layout assistance please  RSS feed

 
Tempora Telora
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

Here is psuedo for what I am doing

JDialog dialog = new JDialog

JPanel text = new JPanel
text.setLayout(flowlayout());
new label
new inputtextfield
text.add(label)
text.add(inputtextfield)

JPanel boxes
boxes.setLayout(new Boxlayout(boxes))
jlabel
boxes


container = dialgog.getcontentpane()
*****boxlayout******
add(text)
add(boxes)

Now I want to add these to a container.setLayout(boxlayout())
but I am unsure of what I can pass to the boxlayout.
Also how do you give the input field and an elipse or ... so they can browse directories and return only the path directory not a file?

Does this seem to be good practice for the gui adding all the jpanels? Is there a better way of doing this?

Thanks,
Lammy
[ May 10, 2007: Message edited by: Randy Tatham ]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> ... so they can browse directories and return only the path directory not a file?

JFileChooser set to 'directories only' might suit
 
Tempora Telora
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yea I am using the DIRECTORIES_ONLY constant. The problem is that on my contentpane I am using a flowlayout and hsould be using a boxlayout but, I cannot figure what to pass the boxlayout because I have 4 different JPanels.

Also my jfilechooser is showing up in the window versus just a button. Should I just do a jlabel jtextfield jbutton[to browse files]? Can I direct the answer of hte browser to the jtextfield?


Thanks,
Lammy
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> I cannot figure what to pass the boxlayout because I have 4 different JPanels.

you would add the 4 panels to the boxlayoutPanel, X or Y axis.

JPanel boxlayoutPanel = new JPanel();
boxlayoutPanel.setLayout(new BoxLayout(boxlayoutPanel,BoxLayout.Y_AXIS));
boxlayoutPanel.add(panel1);
boxlayoutPanel.add(panel2);
etc

> Can I direct the answer of hte browser to the jtextfield?

your button opens the JFileChooser (which is modal), so in your button's actionPerformed()

 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!