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.


>> REGISTER NOW TO START POSTING


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

Results 1 to 4 of 4

Thread: I need help! Airline reservation thing. how does the button function? Help!

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I need help! Airline reservation thing. how does the button function? Help!

    my main:

    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class TicketMan {

    public static void main(String[] args) {
    JFrame frame = new JFrame ("Airport");
    frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
    TicketManBot panel = new TicketManBot();
    frame.getContentPane().add(panel);



    frame.pack();
    frame.setVisible(true);

    }

    }


    the class that it extends from
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.Random;


    public class TicketManBot extends JPanel {


    private JLabel name;
    private JLabel dest;
    private JLabel depc;
    private JLabel dept;
    private JLabel seat;
    private JButton b;


    Random rand = new Random();

    private JTextField namef, destf, depcf, deptf;


    public TicketManBot()

    {



    name = new JLabel ("Enter passenger's name:");
    dest = new JLabel ("Destination: ");
    depc = new JLabel ("Departure city: ");
    dept = new JLabel ("Departure time: ");
    seat = new JLabel ("Seat Number: " + rand.nextInt(100));

    b = new JButton ("Make Reservation");

    b.addActionListener (new Action());

    namef = new JTextField (10);
    destf = new JTextField (10);
    depcf = new JTextField (10);
    deptf = new JTextField (10);
    }{
    add (name);
    add (namef);
    add (dest);
    add (destf);
    add (depc);
    add (depcf);
    add (dept);
    add (deptf);
    add (seat);
    add (b);


    setPreferredSize (new Dimension(200, 300));
    setBackground (Color.gray);
    }
    private class TempListener implements ActionListener
    {
    public void actionPerformed (ActionEvent event)
    {
    int resultLabel;

    String text = namef.getText();
    }}
    static class Action implements ActionListener {
    public void actionPerformed (ActionEvent e){
    JFrame results = new JFrame("clicked");
    results.setVisible(true);
    results.setSize(200, 200);
    JLabel label = new JLabel ("you clicked me");
    JPanel panel = new JPanel ();
    results.add(panel);
    panel.add (label);
    }
    }
    }


    I'm trying to make the button open a new frame but it gives me errors. HELP....please


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: I need help! Airline reservation thing. how does the button function? Help!

    Please use code tags when posting code. See the announcements page for instructions on code tags.

    Always include the full text of the error message with your code and question

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: I need help! Airline reservation thing. how does the button function? Help!

    You asked in the chat box about a Java live chat. There are a couple of Java programming RSS feeds that are pretty active and usually manned. Forums like this one can be more patient, and they are a better forum for communicating your questions and for volunteers to help you, but the responses may not be as immediate as you'd like. If you're in a hurry, next time don't wait until the night it's due to ask for help.

  4. #4
    Junior Member
    Join Date
    Dec 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I need help! Airline reservation thing. how does the button function? Help!

    It's due in 4 days so yeahh

Similar Threads

  1. flight reservation code problem...
    By ricaclaire16 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: March 4th, 2012, 09:07 AM
  2. Airline Management Simulation Game
    By aussiemcgr in forum The Cafe
    Replies: 23
    Last Post: July 8th, 2011, 03:59 PM
  3. problem with choice for airline reservation
    By chonch in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 6th, 2011, 10:30 PM
  4. Java Assignment 2011 - reservation
    By bs09it in forum Member Introductions
    Replies: 2
    Last Post: March 1st, 2011, 08:25 PM