sample tree

This commit is contained in:
rusefillc 2022-01-27 22:55:03 -05:00
parent 63600e33e7
commit 1f6684fb8f
1 changed files with 11 additions and 2 deletions

View File

@ -13,6 +13,9 @@ import org.jetbrains.annotations.NotNull;
import org.putgemin.VerticalFlowLayout; import org.putgemin.VerticalFlowLayout;
import javax.swing.*; import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.MutableTreeNode;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -43,7 +46,11 @@ public class LiveDataPane {
JPanel legend = populateLegend(); JPanel legend = populateLegend();
JPanel leftList = new JPanel(new VerticalFlowLayout()); // DefaultMutableTreeNode root = new DefaultMutableTreeNode("JTree");
JTree leftList = new JTree();
leftList.setRootVisible(false);
DefaultTreeModel model = (DefaultTreeModel) leftList.getModel();
MutableTreeNode root = (MutableTreeNode) model.getRoot();
for (live_data_e view : live_data_e.values()) { for (live_data_e view : live_data_e.values()) {
String fileName = StateDictionary.INSTANCE.getFileName(view) + CPP_SUFFIX; String fileName = StateDictionary.INSTANCE.getFileName(view) + CPP_SUFFIX;
Field[] values = StateDictionary.INSTANCE.getFields(view); Field[] values = StateDictionary.INSTANCE.getFields(view);
@ -55,7 +62,9 @@ public class LiveDataPane {
// we want focus there so that mouse wheel scrolling would be active // we want focus there so that mouse wheel scrolling would be active
scroll.requestFocus(); scroll.requestFocus();
}); });
leftList.add(shortCut); DefaultMutableTreeNode child = new DefaultMutableTreeNode(fileName);
model.insertNodeInto(child, root, root.getChildCount());
vertical.add(liveDataParserContent, "grow, wrap"); vertical.add(liveDataParserContent, "grow, wrap");
} }