Results 1 to 2 of 2
  1. #1
    dudedatroz is offline Member
    Join Date
    Feb 2010
    Posts
    1
    Rep Power
    0

    Post Stack Implemented Linked List HELP!!!!!!!!!

    Hello everybody, im very new to netbeans and just stated GUI with java.
    i want to program a stack implemented linked list with GUI interface. I have the coding for the cmd but i dont know how put those codings to netbeans and retrieve the data from a jlist or a jtextfield.

    there must be a jtextfield and a jbutton to add the names to a jlist and there must be a button to sort the last entered names to be displayed first and a delete button to delete items with (pop) method .

    here's the coding i have for the cmd, if anyone can tell me how to do it in netbeans its highly appreciated.. thank you so much,

    /////////////////////////////////////////////////////////////////////////////
    import java.io.*;

    class Link

    {

    public String names;
    public Link next;
    public Link(String dd)
    { names = dd; }


    public void displayLink()
    {

    System.out.println(names + " ");


    }

    }


    class LinkList

    {

    private Link first;
    public LinkList()

    {first = null;}

    public boolean isEmpty()

    {return (first==null);}

    public void insertFirst(String dd)

    {

    Link newLink = new Link(dd);

    newLink.next = first;
    first = newLink;

    }



    public String deleteFirst()

    {


    Link temp = first;

    first = first.next;

    return temp.names;

    }

    public void displayList()

    {


    Link current = first;
    while(current !=null)


    {
    current.displayLink();
    current = current.next;

    }


    System.out.println("");

    }

    }


    class LinkStack

    {

    private LinkList theList;

    public LinkStack()

    {

    theList = new LinkList();

    }


    public void push(String j)

    {

    theList.insertFirst(j);

    }

    public String pop()

    {

    return theList.deleteFirst();

    }


    public boolean isEmpty()

    {

    return (theList.isEmpty());

    }

    public void displayStack()

    {

    System.out.println("Stack All names (top-->bottom):");

    System.out.println("");

    theList.displayList();

    }

    public void displayStackz()

    {

    System.out.println("Stack After Deleting 2 Latest names (top-->bottom):");

    System.out.println("");

    theList.displayList();

    }

    }


    class empnames

    {

    public static void main(String args []) throws IOException

    {



    LinkStack theStack = new LinkStack();

    theStack.push("1. Peter");
    theStack.push("2. Brown");
    theStack.push("3. Sam");
    theStack.push("4. Chinho");
    theStack.push("5. Jade");
    theStack.push("6. Harry");
    theStack.push("7. Maleena");
    theStack.push("8. Bruce");
    theStack.push("9. Matt");
    theStack.push("10. Jo");

    theStack.displayStack();

    theStack.pop();
    theStack.pop();

    theStack.displayStackz();

    }

    }

    the names should be displayed from 10(first) to 1(last).

    Please HELP...
    thanx.

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

    Default

    To do GUI coding in Swing, you must study from the source. Please have a look here for an excellent tutorial: Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials)

    Much luck and welcome to the forum. Oh, and also, please look at my signature below for tips on using code tags here.

Similar Threads

  1. Linked List
    By basma in forum JCreator
    Replies: 0
    Last Post: 02-03-2010, 08:34 AM
  2. Linked list
    By rosh72851 in forum New To Java
    Replies: 1
    Last Post: 02-05-2009, 07:21 AM
  3. Linked List integer list
    By igniteflow in forum Advanced Java
    Replies: 1
    Last Post: 12-10-2008, 08:53 PM
  4. Linked List help
    By neobie in forum New To Java
    Replies: 8
    Last Post: 12-22-2007, 03:15 AM
  5. Help with linked list
    By trill in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 07:29 AM

Posting Permissions

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