Hi, I have a problem of modifying Jtree font. No matter what I do or make changes in code I'm unable to change the default font. I got the TreeCellRenderer code from some website. Any suggesion on font change would be really helpful class MyCellRenderer extends JEditorPane implements TreeCellRenderer { JEditorPane dummy = new JEditorPane(); final Font TABLE_FONT = new Font("SansSerif", Font.PLAIN, 12); final Font TABLE_FONT_SELECTED = new Font("SansSerif", Font.BOLD, 12); final Font TABLE_FONT_ROOT = new Font("SansSerif", Font.ITALIC, 12); MyCellRenderer() { setContentType("text/html"); dummy.setContentType("text/html"); dummy.setFont(new FontUIResource("Helvetica",Font.BOLD,2)); dummy.setFont(new Font("Helvetica",Font.BOLD,2)); dummy.setBackground(UIManager.getColor(test.p6.getBackground())); } public Component getTreeCellRendererComponent(javax.swing.JTree tree,Object obj,boolean isSelected, boolean isExtended, boolean isLeaf, int …

Member Avatar
Member Avatar
+0 forum 1

I created a JTree from an XML file like this: //Load Tree from XML file File stocks = new File("//Users/scott/Desktop/saSample.xml"); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); doc = dBuilder.parse(stocks); doc.getDocumentElement().normalize(); // Set root folder DefaultMutableTreeNode rootnode = new DefaultMutableTreeNode(doc.getDocumentElement().getAttribute("saName")); DefaultTreeModel treeModel = new DefaultTreeModel(rootnode); objMgrTree.setModel(treeModel); // Set Pages as sub-folders NodeList nodes = doc.getElementsByTagName("Page"); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); DefaultMutableTreeNode pagenode = new DefaultMutableTreeNode(node.getAttributes().getNamedItem("saName").getNodeValue()); rootnode.add(pagenode); //Iterate through each page element to find all elements under it NodeList subnodes = node.getChildNodes(); for (int j = 0; j < subnodes.getLength(); j++) …

Member Avatar
+0 forum 0

Please help me...How to connect a jfilechooser and a jtree that takes the file system view of my pc..i need whenever a node is selected in jtree it automatically set as a current directory in the jfilechooser..

Member Avatar
Member Avatar
+0 forum 3

Hey there, is there a way to convert a string to a tree path? i can convert a path to a string, but not the other way around... [CODE]jTree1.getSelectionPath().toString()[/CODE] thats the only way i know.. nooo idea how to convert it back??

Member Avatar
Member Avatar
+0 forum 2

I want to make node heights of JTree nodes to differ. I mean like the parents have different node height and childs have different node height. I tried to put myJTree.setRowHeight(30) while adding nodes but it doesn't work because it does not work for a single node but for the whole tree. Is there any way to get it done?

Member Avatar
Member Avatar
+1 forum 8

I am facing a strange problem, and seriously I spend lot of time in experimenting different things to get it work but all in vain. I have a JTree whose nodes are been modified by my custom TreeCellRenderer class. My class creates a JPanel for every node and places components over that panel and assign various values to them and then the node is created. I have a JLabel on it whose purpose is to display avatar of users fetched from the google talk server. Now the problem is that, the avatar icons get displayed on the jlabel when I …

Member Avatar
Member Avatar
+0 forum 1

I want to expand my Jtree nodes into multiple lines. Any idea for how to achieve this?

Member Avatar
Member Avatar
+0 forum 16

Hi all, I have a JTree (JXTreeTable actually, but anyway, it should be similar). I use setShowsRootHandles(true), but the handles are not displayed. Do you know what may cause the problem? My current look and feel settings support these kinds of things. Thanks in advance.

Member Avatar
+0 forum 0

Hi all, I've been struggling with a Swing issue for days now, maybe someone can help me :) I would like to see several icons at the left hand side of a JTree element. Is that possible? I mean i know that I have to create some tricky cell renderer class, but how do i make it accept a list of images? Thanks in advance, Tamas

Member Avatar
Member Avatar
+0 forum 2

i need to a Scroll bar or JScrollPane to My Jtree... I have googled and gone through several examples, but non seemed to have worked... Please can some one help me to solve this problem .. I simply need to have scrollers when the content of the JTree increases .. My Code :: [code] import java.awt.BorderLayout; import javax.swing.JFrame; import javax.swing.JButton; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JTree; import java.awt.Rectangle; import javax.swing.JScrollBar; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JPanel; public class Frame1 extends JFrame { BorderLayout borderLayout1 = new BorderLayout(); JButton jButton1 = new JButton(); JTree jTree1 = new JTree(); JSplitPane jSplitPane1 = …

Member Avatar
Member Avatar
+0 forum 14

The End.