X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fdemos%2FDemoTreeViewWindow.java;h=e31ef765ba7b9df1386996ed7dba811b3c42dac7;hb=43ad7b6c509c45c8f261e77ea059c10fed8c9f1c;hp=ad588a916acdca4f8957287fac54d24ba3df3381;hpb=2ce6dab2bbd951e6d0f09f94759efda5ee4b65ac;p=fanfix.git diff --git a/src/jexer/demos/DemoTreeViewWindow.java b/src/jexer/demos/DemoTreeViewWindow.java index ad588a9..e31ef76 100644 --- a/src/jexer/demos/DemoTreeViewWindow.java +++ b/src/jexer/demos/DemoTreeViewWindow.java @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (C) 2016 Kevin Lamonte + * Copyright (C) 2017 Kevin Lamonte * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -32,6 +32,7 @@ import java.io.IOException; import jexer.*; import jexer.event.*; +import jexer.ttree.*; import static jexer.TCommand.*; import static jexer.TKeypress.*; @@ -40,10 +41,18 @@ import static jexer.TKeypress.*; */ public class DemoTreeViewWindow extends TWindow { + // ------------------------------------------------------------------------ + // Variables -------------------------------------------------------------- + // ------------------------------------------------------------------------ + /** * Hang onto my TTreeView so I can resize it with the window. */ - private TTreeView treeView; + private TTreeViewWidget treeView; + + // ------------------------------------------------------------------------ + // Constructors ----------------------------------------------------------- + // ------------------------------------------------------------------------ /** * Public constructor. @@ -55,7 +64,7 @@ public class DemoTreeViewWindow extends TWindow { super(parent, "Tree View", 0, 0, 44, 16, TWindow.RESIZABLE); // Load the treeview with "stuff" - treeView = addTreeView(1, 1, 40, 12); + treeView = addTreeViewWidget(1, 1, 40, 12); new TDirectoryTreeItem(treeView, ".", true); statusBar = newStatusBar("Treeview demonstration"); @@ -65,6 +74,10 @@ public class DemoTreeViewWindow extends TWindow { statusBar.addShortcutKeypress(kbF10, cmExit, "Exit"); } + // ------------------------------------------------------------------------ + // TWindow ---------------------------------------------------------------- + // ------------------------------------------------------------------------ + /** * Handle window/screen resize events. * @@ -73,10 +86,10 @@ public class DemoTreeViewWindow extends TWindow { @Override public void onResize(final TResizeEvent resize) { if (resize.getType() == TResizeEvent.Type.WIDGET) { - // Resize the text field - treeView.setWidth(resize.getWidth() - 4); - treeView.setHeight(resize.getHeight() - 4); - treeView.reflow(); + // Resize the treeView field + TResizeEvent treeSize = new TResizeEvent(TResizeEvent.Type.WIDGET, + resize.getWidth() - 4, resize.getHeight() - 4); + treeView.onResize(treeSize); return; }