set layout of container to flowlayout

Hi.Could someone please help me with the following .. im battling to do this in a program..thank you./* Write code that will set the layout of the container to a Flowlayout,then add all the GUI components to the container */
[245 byte] By [Lizanea] at [2007-11-27 7:41:27]
# 1
Are you just going to post all your homework questions, wholesale, and hope someone does it for you? Not going to happen
georgemca at 2007-7-12 19:22:04 > top of Java-index,Java Essentials,New To Java...
# 2
http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html
hunter9000a at 2007-7-12 19:22:04 > top of Java-index,Java Essentials,New To Java...
# 3
i have been trying to do this for the last two days, it is part of a bigger program and i cant get it right. so it is not that im trying to get someone to do it for me...im asking for help!big difference.
Lizanea at 2007-7-12 19:22:04 > top of Java-index,Java Essentials,New To Java...
# 4

> i have been trying to do this for the last two days,

> it is part of a bigger program and i cant get it

> right. so it is not that im trying to get someone to

> do it for me...im asking for help!big difference.

Did you read the link I gave? Did that answer your question? If not, post what you have so far and what's wrong with it.

hunter9000a at 2007-7-12 19:22:04 > top of Java-index,Java Essentials,New To Java...
# 5

yes i read it, it helped.

This is what i have so far.

public void addComponentsToPane(final Container pane) {

final JPanel compsToExperiment = new JPanel();

compsToExperiment.setLayout(experimentLayout);

experimentLayout.setAlignment(FlowLayout.TRAILING);

JPanel controls = new JPanel();

controls.setLayout(new FlowLayout());

prompt1JLabel = new JButton(prompt1);

prompt1JLabel.setActionCommand(prompt1);

prompt1JLabel.setSelected(true);

prompt2JLabel = new JButton(prompt2);

prompt2JLabel.setActionCommand(prompt2);

//Add buttons to the experiment layout

compsToExperiment.add(new JButton("Button 1"));

compsToExperiment.add(new JButton("Button 2"));

compsToExperiment.add(new JButton("Button 3"));

compsToExperiment.add(new JButton("Long-Named Button 4"));

compsToExperiment.add(new JButton("5"));

//Left to right component orientation is selected by default

compsToExperiment.setComponentOrientation(

ComponentOrientation.LEFT_TO_RIGHT);

Lizanea at 2007-7-12 19:22:04 > top of Java-index,Java Essentials,New To Java...
# 6

> yes i read it, it helped.

> This is what i have so far.

>

>

> public void addComponentsToPane(final Container pane)

> {

> final JPanel compsToExperiment = new

> JPanel();

>

> ompsToExperiment.setLayout(experimentLayout);

>

> xperimentLayout.setAlignment(FlowLayout.TRAILING);

> JPanel controls = new JPanel();

> controls.setLayout(new FlowLayout());

>

> prompt1JLabel = new JButton(prompt1);

> prompt1JLabel.setActionCommand(prompt1);

> prompt1JLabel.setSelected(true);

> prompt2JLabel = new JButton(prompt2);

> prompt2JLabel.setActionCommand(prompt2);

>

> //Add buttons to the experiment layout

> compsToExperiment.add(new JButton("Button

> 1"));

> compsToExperiment.add(new JButton("Button

> 2"));

> compsToExperiment.add(new JButton("Button

> 3"));

> compsToExperiment.add(new JButton("Long-Named

> Button 4"));

>compsToExperiment.add(new JButton("5"));

> //Left to right component orientation is selected by

> default

>compsToExperiment.setComponentOrientation(

> ComponentOrientation.LEFT_TO_RIGHT);

what about :

Container c = getContentPane();

c.setLayout(new FlowLayout());

//create your Panel and add components.

(not tested but it should be good)

deAppela at 2007-7-12 19:22:04 > top of Java-index,Java Essentials,New To Java...