package gradertool.gradebook; import javax.swing.*; import java.awt.*; import javax.swing.plaf.basic.BasicArrowButton; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicTreeUI; /** * Represents the Item Explorer GUI */ public class ItemExplorerDisplay extends JFrame { /** * How far to indent the average percentages */ protected String indent = " "; /** * Layout of the categories and sub-categories */ protected Object[] categories = { "Categories", new Object[] {"Tests" + indent + "86%", new Object[] {"Quizzes" + indent + "90%","Q1" + indent + "90%"}, new Object[] {"Midterms" + indent + "91%", "M1" + indent + "91%", "M2"}, "Final" + indent + "96%"}, new Object[] {"Programs" + indent + "97%", "Program 1" + indent + "97%"}, new Object[] {"Labs" + indent + "93%","Lab 1" + indent + "93%"} }; /** * Constructs the items for the Item Explorer GUI */ public ItemExplorerDisplay() { Container content = getContentPane(); DefaultMutableTreeNode root = processHierarchy(categories); JTree tree = new JTree(root); tree.setRootVisible(false); setTitle("Item Explorer"); content.add(new JScrollPane(tree), BorderLayout.CENTER); pack(); setSize(300, 300); this.setVisible(true); } /** * Takes the categories and sub-categories array and formats * it to look like a file heirarchy */ private DefaultMutableTreeNode processHierarchy(Object[] hierarchy) { DefaultMutableTreeNode node = new DefaultMutableTreeNode(hierarchy[0]); DefaultMutableTreeNode child; for(int i=1; i