Class BSTFrame

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class BSTFrame extends JFrame
A Frame for creating and manipulating a data structure with functionality equivalent to a binary search tree. The Frame has a text field for entering a String to be used as a key, along with the following buttons:
  • Put - inserts the key into the tree
  • Remove - removes the key from the tree
  • Back - moves backward through the history of trees created
  • Forward - moves forward through the history of trees created
  • Clone - creates a new Frame with an identical tree and identical history
The frame also contains controls for changing the font used to render the trees.
Author:
Rod Howell (rhowell@ksu.edu)
See Also:
  • Constructor Details

    • BSTFrame

      public BSTFrame(BSTInterface t, String title)
      Constructs a BSTFrame for manipulating the given tree.
      Parameters:
      t - the tree to manipulate
      title - the title of the window
    • BSTFrame

      public BSTFrame(BSTInterface t, String title, int size, int style)
      Constructs a BSTFrame for manipulating the given tree.
      Parameters:
      t - the tree to manipulate
      title - the title of the window
      size - the size of the font used for the nodes
      style - the style of the font used for the nodes, as documented in java.awt.Font
      Throws:
      IllegalArgumentException - if size is outside its proper range.
      See Also:
  • Method Details

    • adjustFont

      public void adjustFont()
      Changes the font used to render the tree using values chosen by the user. If either value is illegal, the font is unchanged.
    • put

      public void put()
      Inserts a String provided by the user into the tree.
    • remove

      public void remove()
      Removes a String given by the use from the tree.
    • back

      public void back()
      Goes to the previous tree in the history.
    • forward

      public void forward()
      Goes to the next tree in the history.
    • makeClone

      public void makeClone()
      Creates and displays a clone of this frame.