I've tried many time to solve this problem...but still not successful,

I'm newbie..so anyone of guys can help me check this problem...

  • Button "Back" is big as frame
  • Seems no TextField for NoOfTicket
import javax.swing.*;
import java.awt.*;
//import java.awt.event.*;

public class ticketReservation extends JFrame {

	private JLabel jlbWelcome, jlbReserved, jlbMovie, jlbDate, jlbShowtime, jlbNoOfSeats, jlbPrice, jlbNoOfTicket;
	private JTextField jtfMovie, jtfDate, jtfShowtime, jtfNoOfSeats, jtfPrice, jtfNoOfTicket;
	private JButton jConfirm, jBack;

    Font f=new Font("Times",Font.BOLD,30);
  //Font f1=new Font("Times",Font.BOLD,16);
  //Font f2=new Font("Times",Font.BOLD,12);

	public ticketReservation () {

	jlbWelcome = new JLabel ("Ticket Reservation");
	//add jlbWelcome to the form
	add(jlbWelcome);
	jlbWelcome.setBounds(200,50,500,100);
        jlbWelcome.setHorizontalAlignment(jlbWelcome.CENTER );
        jlbWelcome.setFont(f);

    //Label
    jlbMovie = new JLabel("Movie :");
    jlbDate = new JLabel("Date :");
    jlbShowtime = new JLabel("Showtime :");
    jlbNoOfSeats = new JLabel("No of Seats :");
    jlbPrice = new JLabel("Price :");
    jlbNoOfTicket = new JLabel("No Of Tickets :");

    // add all the label on the frame
    add(jlbMovie);
    add(jlbDate);
    add(jlbShowtime);
    add(jlbNoOfSeats);
    add(jlbPrice);
    add(jlbNoOfTicket);

    //Set Positions
    jlbMovie.setBounds(300,140,100,20);
    jlbDate.setBounds(300,180,100,20);
    jlbShowtime.setBounds(300,220,100,20);
    jlbNoOfSeats.setBounds(300,250,100,20);
    jlbPrice.setBounds(300,280,100,20);
    jlbNoOfTicket.setBounds(300,310,100,20);

    // initialize the textfield with size
    jtfMovie = new JTextField(15);
    jtfDate = new JTextField(15);
    jtfShowtime = new JTextField(15);
    jtfNoOfSeats = new JTextField(15);
    jtfPrice = new JTextField(15);
    jtfNoOfTicket = new JTextField(15);

    // add all the label on the frame
    add(jtfMovie);
    add(jtfDate);
    add(jtfShowtime);
    add(jtfNoOfSeats);
    add(jtfPrice);
    add(jtfNoOfTicket);

    // set a particlar position on a screen with setbounds constructor
    jtfMovie.setBounds(400,140,100,20);
    jtfDate.setBounds(400,180,100,20);
    jtfShowtime.setBounds(400,220,100,20);
    jtfNoOfSeats.setBounds(400,250,100,20);
    jtfPrice.setBounds(400,280,100,20);
    jtfNoOfTicket.setBounds(400,320,100,20);




    // Add button
    jConfirm = new JButton("Confirm");
    jBack = new JButton("Back");

    Add tooltip in the buttons
    jConfirm.setToolTipText("Click this button to Add record in the Database.");
    jBack.setToolTipText("Click this button to Save record in the Database.");

    // Add button on a frame
    add(jConfirm);
    add(jBack);

    // set a particular position on a Frame
    jConfirm.setBounds(200,400,100,30);
    jBack.setBounds(310,400,100,30);

    // register all the button
    jConfirm.addActionListener(this);
    jBack.addActionListener(this);


	}


	public static void main (String [] args) {

		ticketReservation frame=new ticketReservation();
   		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setTitle("Ticket Reservation"); //set title of thewindow
		frame.setSize(800,600); //size of the window
		frame.setVisible(true); //visible the window
		frame.setLocationRelativeTo (null); //center the window
	}
}

I know its seems simple for u, but please tell me the problem.. Thank you !

oh ya...i solve it...Thx Mate

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.