Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > Java GUI
Java GUI Discussions specific to programming Java GUI.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java GUI section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 4th, 2003, 07:30 PM
Authorized User
Join Date: Aug 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to egolileopablo Send a message via Yahoo to egolileopablo
Default help on this code

plse thanks for last times code.Eric this is my last assignment for the semister and is due today can you plse help me out. the program is use a priority Queue as its data structure and its encapsulated in an interface. plse help me on how to store data into the queue through the dialog box. the dialog box is gotten when the Add Call button is pressed. the data should be added to the end of the queue by using this method enqueue(WaitingCustomer item) in the interface.

enqueue():add the WaitingCustomer to the end of the queue. if the WaitingCustomer object is a Vip client, the object should be added ahead of all non vip customers(but behind any existing vips in the queue.

dequeue(): make the next Waiting Customer off the queue. if the queue is empty, it should return a null reference.

vipCount(): give a count of number of vips that are currently waiting in the queue.

size(): return the total number of customers waiting waiting in the queue

isEmpty(): return whether or not the queue is empty.

So far this is what i have done to and so plse run it and help me out b4 late today or tommorrow. thanks

/*Author : George Finishdd Gyau
  Date : 2nd November 2003

package star;

//java core packages
import java.awt.*;
import java.awt.event.*;
import java.util.*;

//java extended packages
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import javax.swing.border.TitledBorder;

public class BlueStarAirLine extends JFrame {

  private JPanel customerPanel;
  private JPanel queuePanel;

  //labels and fields for the current customer border
  private JLabel cNlabel;
  private JLabel cTlabel;
  private JLabel Viplabel;
  private JTextField cNfield;
  private JTextField cTfield;

  //labels and fields for the queue functions border
  private JLabel qVlabel;
  private JLabel qTlabel;
  private JTextField qVfield;
  private JTextField qTfield;
  private JButton nbtn;
  private JButton abtn;

  //set up GUI
  public BlueStarAirLine() {
    super("BlueStar AirLine");

    customerPanel = new JPanel();
    customerPanel.setLayout(new GridLayout(0,2,3,3));

    JPanel clfPanel = new JPanel();
    clfPanel.setLayout(new GridLayout(0,2,3,3));

    cNlabel = new JLabel("Name");
    cTlabel = new JLabel("Telephone");
    cNfield = new JTextField(10);
    cTfield = new JTextField(10);



    customerPanel.add(clfPanel, new BorderLayout().EAST);

    JPanel vipPanel = new JPanel();
    JLabel label = new JLabel("VIP Customer");
    vipPanel.add(label, new BorderLayout().SOUTH);
    customerPanel.add(vipPanel, new BorderLayout().WEST);

    queuePanel = new JPanel();
    queuePanel.setLayout(new GridLayout(0,2,3,3));

    JPanel lfPanel = new JPanel();
    lfPanel.setLayout(new GridLayout(0,2,3,3));
    qVlabel = new JLabel("VIPs Waiting");
    qTlabel = new JLabel("Total Waiting");

    qVfield = new JTextField(15);
    qTfield = new JTextField(15);



    JPanel btnPanel = new JPanel();
    btnPanel.setLayout(new GridLayout(0,2,3,3));
    Box box = new Box(BoxLayout.Y_AXIS);
    nbtn = new JButton("Next in Queue");
    abtn = new JButton("Add Call");
    abtn.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) {

        Dialog d = new Dialog();


    btnPanel.add(box, new BorderLayout().WEST);

    queuePanel.add(lfPanel, new BorderLayout().NORTH);
    queuePanel.add(btnPanel, new BorderLayout().SOUTH);

    TitledBorder cborder = BorderFactory.createTitledBorder("Current Customer");
    TitledBorder qborder = BorderFactory.createTitledBorder("Queue Functions");


    //adding the panels to the contentPane().
    getContentPane().add(customerPanel, new BorderLayout().NORTH);
    getContentPane().add(queuePanel, new BorderLayout().SOUTH);


  //the main method
  public static void main(String args[]) {

    BlueStarAirLine airLine = new BlueStarAirLine();


//the add Dialog class
class Dialog extends JDialog {

  private JLabel nlabel;
  private JTextField nfield;
  private JLabel tlabel;
  private JTextField tfield;
  private JCheckBox check;
  private JButton sbtn, cbtn;
  WaitingCustomer item = new WaitingCustomer();
  CustomerQueue queue = new List();

  public Dialog() {
   Container c = getContentPane();

    JPanel pane = new JPanel();
    pane.setLayout(new GridLayout(0,2));
    nlabel = new JLabel("Name");
    nfield = new JTextField(10);

    tlabel = new JLabel("Tel Number");
    tfield = new JTextField(10);

    check = new JCheckBox("Vip Status");
    check.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent item) {
    sbtn = new JButton("Save");
    sbtn.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) {

        String s = (String)nfield.getText();
        String t = (String)tfield.getText();
        //queue.enqueue(item) = t;
    cbtn = new JButton("Cancel");
    cbtn.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ev) {
        JOptionPane.showMessageDialog(Dialog.this, "Vetting Committee was CORRUPT, They all say SOOOOOO!!!");





    JPanel pan = new JPanel();
    pan.setLayout(new FlowLayout());


    c.add(pane, new BorderLayout().NORTH);
    c.add(pan, new BorderLayout().SOUTH);


  private void closeForm(){


interface CustomerQueue {

  public void enqueue(WaitingCustomer item);
  public WaitingCustomer dequeue();
  public int vipCount();
  public int size();
  public boolean isEmpty();


//WaitingCustomer class
class WaitingCustomer {

  private String custName;
  private String telNumber;
  private boolean vipCustomer;

  WaitingCustomer() {


  WaitingCustomer(String name, String tel, boolean vip) {

    custName = name;
    telNumber = tel;
    vipCustomer = vip;


  public String getCustName() {
    return custName;

  public String getTelNumber() {
    return telNumber;

  public boolean getVipCustomer() {
    return vipCustomer;

  public void setCustName(String s) {
    custName = s;

  public void setTelNumber(String t) {
    telNumber = t;

  /*public void setVipCustomer(String v) {
    vipCustomer = v;

//ListNode class
/*class ListNode {
  String namee;
  String tel;
  boolean vip;
  WaitingCustomer cust = new WaitingCustomer(namee,tel,vip);
  ListNode next;

  public ListNode() {


  public ListNode(WaitingCustomer item) {
    cust = item;

//List class
class List implements CustomerQueue {

  ListNode head;
  ListNode tail;
  int size;
  int vipCount;
  WaitingCustomer dequeue;

  List() {
    head = null;
    size = 0;

  public void enqueue(WaitingCustomer item) {

    ListNode newNode = new ListNode();

      if (size == 0)
         head = newNode;
         tail = head;
         tail = tail.getNext();


  public WaitingCustomer dequeue() throws EmptyQueueException {
    WaitingCustomer data;

      if (size == 0)
         throw new EmptyQueueException();
         data = head.getData();
         head = head.getNext();

      return data;

  public int vipCount() {

   return vipCount;


  public int size() {

      return size;


  public boolean isEmpty() {

      return true;


// Exception class
class EmptyQueueException extends Exception

class ListNode
   private ListNode next;
   private WaitingCustomer data;

      next = null;
      data = null;

   ListNode(WaitingCustomer inData)
      next = null;
      data = inData;

   ListNode(WaitingCustomer inData, ListNode inNext)
      next = inNext;
      data = inData;

   WaitingCustomer getData()
      return data;

   void setData(WaitingCustomer inData)
      data = inData;

   ListNode getNext()
      return next;

   void setNext(ListNode inNext)
      next = inNext;


Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent:hard disk serial code and vb code ivanlaw Pro VB 6 0 July 25th, 2007 04:05 AM
VB: .Exe file, serial code and activation code ivanlaw Pro VB 6 8 July 6th, 2007 05:44 AM
code clinic - Why wont example asp code work? jardbf Classic ASP Basics 3 April 27th, 2006 06:22 PM
Writing Client Side Script from Code-Behind code sajid_pk Classic ASP Databases 1 January 18th, 2005 12:53 AM
disable forum code within [code] blocks? nikolai Forum and Wrox.com Feedback 0 October 23rd, 2003 07:52 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.