Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: I am having major issues with layouts

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Thanked 0 Times in 0 Posts

    Default I am having major issues with layouts

    This is my first post, so Hello! I should have started sooner in the semester. I am not asking for anyone to do my homework...I have the following code written but i cannot get my layout to look right.

    the code is incomplete, because I havent done all my calculations and outputs, but I need my layout to work first. I KNOW I am using the wrong method, but I would love for someone to point me in the right direction...

    	Chapter 6:	Buy Movie Tickets
    	Programmer:	Loyd Arthur
    	Date:		2/8/2012
    	Filename:	Movies.java
    	Purpose:	This program allows you to buy a number of tickets for a movie and specify
    				whether it is a matinee or not
    import java.awt.*;
    import java.awt.event.*;
    public class Movies extends Frame implements ActionListener, ItemListener
    	Panel layout;
    	Label titleLabel = new Label("Welcome to Celebration Movies");
    	Label answerLabel = new Label("");
    	Choice movieList = new Choice();
    	Choice numberOfTickets = new Choice();
    	Button calculateButton = new Button("Calculate");
    	String movieTitle;
    	int tickets;
    	double ticketPrice, totalPrice;
    	public Movies()
    		//set the layout
    		setLayout(new BorderLayout());
    		add(titleLabel, BorderLayout.NORTH);
    		add(movieList, BorderLayout.NORTH);
    		add(numberOfTickets, BorderLayout.CENTER);
    		add(calculateButton, BorderLayout.SOUTH);
    		add(answerLabel, BorderLayout.SOUTH);
    		movieList.add("Fight Club");
    		movieList.add("Blade Runner");
    	    movieList.add("The Lord of the Ring: The Two Towers");
    			for(int i = 1; i<=8; i++)
    		//override the windowClosing event
    			new WindowAdapter()
    					public void windowClosing(WindowEvent e)
    	public void itemStateChanged(ItemEvent e)
    				String arg = movieList.getSelectedItem();
    				if (arg == "Fight Club")
    				movieTitle = ("Fight Club");
    				if (arg == "Limitless")
    				movieTitle = ("Limitless");
    				if (arg == "Hackers")
    				movieTitle = ("Hackers");
    				if (arg == "Blade Runner")
    				movieTitle = ("Blade Runner");
    				if (arg == "300")
    				movieTitle = ("300");
    				if (arg == "The Lord of the Ring: The Two Towers")
    				movieTitle = ("The Lord of the Ring: The Two Towers");
    				String arg = numberOfTickets.getSelectedItem();
    				if (arg == "1")
    				tickets =1;
    				if (arg == "2")
    				tickets =2;
    				if (arg == "3")
    				tickets =3;
    				if (arg == "4")
    				tickets =4;
    				if (arg == "5")
    				tickets =5;
    				if (arg == "6")
    				tickets =6;
    				if (arg == "7")
    				tickets =7;
    				if (arg == "8")
    				tickets =8;
    		public void actionPerformed(ActionEvent e)
    				String clicked = e.getActionCommand();
    					if(clicked == "Calculate")
    						totalPrice = (tickets * ticketPrice);
    		public static void main(String[] args)
    		   	// set frame properties
    			Movies f = new Movies();
    	      	f.setTitle("Celebration Movies");

    Thanks in advance and sorry to be begging so drastically on my first post

  2. #2
    Junior Member
    Join Date
    Mar 2012
    Thanked 0 Times in 0 Posts

    Default Re: I am having major issues with layouts

    I went with a GridLayout(6,0) because I have six items for the program...

    it looks like crap, but im under the gun, so function over form today...

    I still wouldn't mind a way to make the program look better for future reference.

Similar Threads

  1. Need major help with a program for class
    By burnenator in forum What's Wrong With My Code?
    Replies: 7
    Last Post: November 20th, 2011, 10:55 PM
  2. Major Help Needed!
    By Rads23 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 13th, 2011, 10:03 AM
  3. Help with Layouts and Panels
    By Zookey in forum What's Wrong With My Code?
    Replies: 0
    Last Post: January 29th, 2011, 06:48 PM
  4. Positioning elements. Is it possible without layouts?
    By goodguy in forum AWT / Java Swing
    Replies: 6
    Last Post: January 21st, 2011, 02:24 PM
  5. need help in major project
    By h313 in forum The Cafe
    Replies: 1
    Last Post: August 1st, 2010, 10:58 AM