Skip to Main Content

FlowLayout and Jlabels and Jbuttons, Help!!!!!

843807Apr 20 2010 — edited Jun 10 2010
Ok, I have an Assignment using the FlowLayout only!!. I have been readin all the tutorials and documentation regarding the FlowLayout. Yet it seems I have a problem. Within my prrogram I am to position the buttons on the right and postion the text on the left.

My question is: Is there a way to postion each component separtely using FlowLayout. Can yoo position the Jlabels to the left and the JButtons to the right?
I know other layouts would be easier but our proffessor wants us to use the flowlayout for this assignment.

Here is my code
import javax.swing.*; 
import java.awt.*;
import java.awt.FlowLayout;
import java.awt.Font;
			
			public class VideoStore extends JFrame {
				JButton b1, b2, b3;
				JLabel movie1,movie2,movie3,header;
			public VideoStore (String title) {
				
				super (title);
				setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				FlowLayout video = new FlowLayout(FlowLayout.LEFT);
			    setLayout(video);
				
				header = new JLabel("CCAC VideoStore");
				header.setFont(new Font("Times New Roman", Font.BOLD, 24));
    			add(header);
			    
    			
    			{movie1= new JLabel("Johnson Family Vacation");
    			movie1.setFont(new Font("Courier New", Font.BOLD, 14));
				add(movie1);
				b1= new JButton("Buy");
				video.setAlignment(FlowLayout.RIGHT);
				add(b1);}
				
				movie2= new JLabel("PitchBlack");
   				 movie2.setFont(new Font("Courier New", Font.BOLD, 14));
			    add(movie2); 
				b2 = new JButton ("Buy");
				add(b2);
				
				movie3= new JLabel ("Meet The Fockers");
    			movie3.setFont(new Font("Courier New", Font.BOLD, 14));
			    add(movie3);
				b3 = new JButton ("Buy");
				add(b3);
			
			}
			}
Edited by: ConfusedNewb on Apr 20, 2010 8:10 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked due to inactivity on Jul 8 2010
Added on Apr 20 2010
5 comments
993 views