Help placing images in JFrame
Ok, I would like to add a row of 10 images between the QuestionLabel which is centered, and the Buttons which are south. The images to be added are 10 of the ImageIcon icon2. Is there a way to place these all lined up in a row in such a specific location.
Here is the code
Code:
public QuestionsFrame(Sequencer theSequencer,String anIcon,String q,String b1,String b2,String b3,String b4,int a)
{
//this.frame = frame;
// this.counter = counter;
answer = a;
theicon = anIcon;
// mario1.aSequencer1 = theSequencer;
//Theframe = Theframe;
// Question = q;
Question = q;
B1 = b1;
B2 = b2;
B3 = b3;
B4 = b4;
//size the frame
setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);
cp = getContentPane();
cp.setBackground(Color.white);
//create Icon object and set its location
ImageIcon icon = new ImageIcon("C:\\users\\Matt\\Documents\\" + theicon);
ImageIcon icon2 = new ImageIcon ("C:\\users\\Matt\\Documents\\coin.jpg");
// ImageIcon icon1 = new ImageIcon("C:\\users\\Matt\\Documents\\mario1.gif");
JButton button1 = new JButton(new AnswerAction(B1,answer ==1,questionNumber)); //create button
JButton button2 = new JButton(new AnswerAction(B2,answer ==2,questionNumber));
JButton button3 = new JButton(new AnswerAction(B3,answer==3,questionNumber));
JButton button4 = new JButton(new AnswerAction(B4,answer==4,questionNumber));
ImagePanel = new JPanel();
ImagePanel.setBackground(Color.white);
//ImagePanel1 = new JPanel();
QuestionPanel = new JPanel();
// QuestionPanel.setBackground(Color.BLUE);
add(ImagePanel,BorderLayout.NORTH);
//add(ImagePanel,BorderLayout.SOUTH);
newLabel = new JLabel();
//add the icon to the label
// newLabel.setLocation(29,40);
newLabel.setPreferredSize((new Dimension(600,450)));
newLabel.setIcon(icon);
// newLabel.setSize(icon.getImage().getWidth(null), icon.getImage().getHeight(null));
// newLabel1.setIcon(icon1);
ImagePanel.add(newLabel);
//ImagePanel2.setLocation(200,10);
//ImagePanel1.add(newLabel1);
QuestionPanel.add(button1); // adding button to frame
QuestionPanel.add(button2);
QuestionPanel.add(button3);
QuestionPanel.add(button4);
add(QuestionPanel,BorderLayout.SOUTH);
QuestionLabel = new JLabel(Question,JLabel.CENTER);
add(QuestionLabel,BorderLayout.CENTER);
}//end of QuestionFrame Contstructor