Results 1 to 3 of 3
  1. #1
    jonywalker123 is offline Member
    Join Date
    Feb 2009
    Posts
    2
    Rep Power
    0

    Default Queue in the GUI

    Hi guys,

    i am developing a java program about a bank, with customers and tellers.

    About the GUI:
    I am using the MVC, so i have the viewer with only two buttons (Start and finish). The program will only deal with those buttons. And when the program runs you can watch the bank interaction. The first in the queue is sent to the teller and the queue is updated going every customer one step forward.

    i developed the java queue with LinkedListed method and now, i am using the JTextArea to add queue info into the textArea. Each line of the textArea will have specific info about the customer and his correspondent type of transaction.

    1. I can not manage to see even the empty JTextArea. How is it possible? I added the following methods to add the text area. Do I need to add something else?

    CustomerQueue = new JTextArea(15, 5);
    CustomerQueue.setSize(5, 15);
    Font f2 = new Font ("Serif", Font.BOLD, 14);
    CustomerQueue.setFont(f2);
    CustomerQueue.setOpaque(false);
    CustomerQueue.setEditable(false);


    2. Then, I tried using the append method to insert a line at the end of the JTextArea. Is that all right? How can i implement the methods used by the queue, push and pop? push=append? pop=?

    thanks very much for your help,

    Jon

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    1. I can not manage to see even the empty JTextArea. How is it possible?
    This is usually due to using the wrong layout manager or the right layout manager incorrectly. Which one is being used in the component that accepts the JTextArea?

    2. Then, I tried using the append method to insert a line at the end of the JTextArea. Is that all right? How can i implement the methods used by the queue, push and pop? push=append? pop=?
    I'm not as sure about this one. You may need to work with the Document object that is the model for the JTextArea.

  3. #3
    dlorde is offline Senior Member
    Join Date
    Jun 2008
    Posts
    339
    Rep Power
    6

    Default

    Quote Originally Posted by jonywalker123 View Post
    2. Then, I tried using the append method to insert a line at the end of the JTextArea. Is that all right?
    I don't see why not, as long as you remember to use a newline character if you want a new line. The best way to find out if it's what you want is to try it.

    How can i implement the methods used by the queue, push and pop? push=append? pop=?
    Ouch! Have a look at the JTextArea API docs - in principle, you could use the line offset methods that allow you to find the start and end of a line by number, and the replaceRange method that allows you to replace a range of characters with a String - which can be empty for deleting a line, and getText that allows you to get a length of text from a given offset...

    But it will be a lot of work. A text area would not be my component of choice for a queue of text lines - it would be a lot simpler with a JList using a DefaultListModel. The DefaultListModel allows you to directly add or remove items from the list, get the first and the last, or any item by index, extract them as an array, etc.

Similar Threads

  1. a Queue of customer in the GUI
    By jonywalker123 in forum Advanced Java
    Replies: 2
    Last Post: 02-26-2009, 11:02 PM
  2. Queue List
    By nahid in forum Advanced Java
    Replies: 4
    Last Post: 10-08-2008, 08:50 AM
  3. Declaring a Queue
    By rhm54 in forum New To Java
    Replies: 1
    Last Post: 03-21-2008, 05:02 AM
  4. Help with queue array please!!
    By vmcg105 in forum New To Java
    Replies: 1
    Last Post: 03-08-2008, 07:03 PM
  5. Using a queue
    By Krmeus in forum New To Java
    Replies: 0
    Last Post: 12-10-2007, 03:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •