Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
files.addElement(thisObject)
# Pass two: for files.
for i in xrange(0, files.size()):
f = files.elementAt(i)
#if f.split('.')[-1] != 'html':
curDir.add(DefaultMutableTreeNode(files.elementAt(i)))
return curDir
if __name__ == "__main__":
frame = JFrame("FileTree")
frame.setForeground(Color.black)
frame.setBackground(Color.lightGray)
cp = frame.getContentPane()
cp.add(FileTree().this)
frame.pack()
frame.setVisible(True)
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
def add_tree_selection_listener(self, listener):
"""
Wrapper for the inner tree selection listener callback register function
:param listener: a new listener
:return: None
"""
self._tree.addTreeSelectionListener(listener)
if __name__ == "__main__":
frame = JFrame("FileTree")
frame.setForeground(Color.black)
frame.setBackground(Color.lightGray)
cp = frame.getContentPane()
cp.add(FileTree().this)
frame.pack()
frame.setVisible(True)
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
def __init__(self, dir=None, label=None):
try:
FileTree.selves.append(self)
except AttributeError:
FileTree.selves = []
FileTree.selves.append(self)
if not dir: dir = os.getcwd()
if not label: label = "FileTree"
dir = File(dir)
self.dir = dir
self.this = JPanel()
self.this.setLayout(BorderLayout())
# Add a label
self.this.add(BorderLayout.PAGE_START, JLabel(label))
# Make a tree list with all the nodes, and make it a JTree
tree = JTree(self.addNodes(None, dir))
tree.setRootVisible(False)
self.tree = tree
# Lastly, put the JTree into a JScrollPane.