Display files also in tree?

hai, to every one
This program displaying folders from the local system, But my problem is, it was not displaying files.
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.*;
public class FileTree1
  extends JFrame
  public static final ImageIcon ICON_COMPUTER =
    new ImageIcon("computer.gif");
  public static final ImageIcon ICON_DISK =
    new ImageIcon("disk.gif");
  public static final ImageIcon ICON_FOLDER =
    new ImageIcon("folder.gif");
  public static final ImageIcon ICON_EXPANDEDFOLDER =
    new ImageIcon("expandedfolder.gif");
  protected JTree  m_tree;
  protected DefaultTreeModel m_model;
  protected JTextField m_display;
  public FileTree1()
    super("Directories Tree");
    setSize(400, 300);
    DefaultMutableTreeNode top = new DefaultMutableTreeNode(
      new IconData(ICON_COMPUTER, null, "Computer"));
    DefaultMutableTreeNode node;
    File[] roots = File.listRoots();
    for (int k=0; k<roots.length; k++)
      node = new DefaultMutableTreeNode(new IconData(ICON_DISK,
        null, new FileNode(roots[k])));
      top.add(node);
                        node.add( new DefaultMutableTreeNode(new Boolean(true)));
    m_model = new DefaultTreeModel(top);
    m_tree = new JTree(m_model);
                m_tree.putClientProperty("JTree.lineStyle", "Angled");
    TreeCellRenderer renderer = new
      IconCellRenderer();
    m_tree.setCellRenderer(renderer);
    m_tree.addTreeExpansionListener(new
      DirExpansionListener());
    m_tree.addTreeSelectionListener(new
      DirSelectionListener());
    m_tree.getSelectionModel().setSelectionMode(
      TreeSelectionModel.SINGLE_TREE_SELECTION);
    m_tree.setShowsRootHandles(true);
    m_tree.setEditable(false);
    JScrollPane s = new JScrollPane();
    s.getViewport().add(m_tree);
    getContentPane().add(s, BorderLayout.CENTER);
    m_display = new JTextField();
    m_display.setEditable(false);
    getContentPane().add(m_display, BorderLayout.NORTH);
    WindowListener wndCloser = new WindowAdapter()
      public void windowClosing(WindowEvent e)
        System.exit(0);
    addWindowListener(wndCloser);
    setVisible(true);
  DefaultMutableTreeNode getTreeNode(TreePath path)
    return (DefaultMutableTreeNode)(path.getLastPathComponent());
  FileNode getFileNode(DefaultMutableTreeNode node)
    if (node == null)
      return null;
    Object obj = node.getUserObject();
    if (obj instanceof IconData)
      obj = ((IconData)obj).getObject();
    if (obj instanceof FileNode)
      return (FileNode)obj;
    else
      return null;
    // Make sure expansion is threaded and updating the tree model
    // only occurs within the event dispatching thread.
    class DirExpansionListener implements TreeExpansionListener
        public void treeExpanded(TreeExpansionEvent event)
            final DefaultMutableTreeNode node = getTreeNode(
                event.getPath());
            final FileNode fnode = getFileNode(node);
            Thread runner = new Thread()
              public void run()
                if (fnode != null && fnode.expand(node))
                  Runnable runnable = new Runnable()
                    public void run()
                       m_model.reload(node);
                  SwingUtilities.invokeLater(runnable);
            runner.start();
        public void treeCollapsed(TreeExpansionEvent event) {}
  class DirSelectionListener
    implements TreeSelectionListener
    public void valueChanged(TreeSelectionEvent event)
      DefaultMutableTreeNode node = getTreeNode(
        event.getPath());
      FileNode fnode = getFileNode(node);
      if (fnode != null)
        m_display.setText(fnode.getFile().
          getAbsolutePath());
      else
        m_display.setText("");
  public static void main(String argv[])
    new FileTree1();
class IconCellRenderer
  extends    JLabel
  implements TreeCellRenderer
  protected Color m_textSelectionColor;
  protected Color m_textNonSelectionColor;
  protected Color m_bkSelectionColor;
  protected Color m_bkNonSelectionColor;
  protected Color m_borderSelectionColor;
  protected boolean m_selected;
  public IconCellRenderer()
    super();
    m_textSelectionColor = UIManager.getColor(
      "Tree.selectionForeground");
    m_textNonSelectionColor = UIManager.getColor(
      "Tree.textForeground");
    m_bkSelectionColor = UIManager.getColor(
      "Tree.selectionBackground");
    m_bkNonSelectionColor = UIManager.getColor(
      "Tree.textBackground");
    m_borderSelectionColor = UIManager.getColor(
      "Tree.selectionBorderColor");
    setOpaque(false);
  public Component getTreeCellRendererComponent(JTree tree,
    Object value, boolean sel, boolean expanded, boolean leaf,
    int row, boolean hasFocus)
    DefaultMutableTreeNode node =
      (DefaultMutableTreeNode)value;
    Object obj = node.getUserObject();
    setText(obj.toString());
                if (obj instanceof Boolean)
                  setText("Retrieving data...");
    if (obj instanceof IconData)
      IconData idata = (IconData)obj;
      if (expanded)
        setIcon(idata.getExpandedIcon());
      else
        setIcon(idata.getIcon());
    else
      setIcon(null);
    setFont(tree.getFont());
    setForeground(sel ? m_textSelectionColor :
      m_textNonSelectionColor);
    setBackground(sel ? m_bkSelectionColor :
      m_bkNonSelectionColor);
    m_selected = sel;
    return this;
  public void paintComponent(Graphics g)
    Color bColor = getBackground();
    Icon icon = getIcon();
    g.setColor(bColor);
    int offset = 0;
    if(icon != null && getText() != null)
      offset = (icon.getIconWidth() + getIconTextGap());
    g.fillRect(offset, 0, getWidth() - 1 - offset,
      getHeight() - 1);
    if (m_selected)
      g.setColor(m_borderSelectionColor);
      g.drawRect(offset, 0, getWidth()-1-offset, getHeight()-1);
    super.paintComponent(g);
class IconData
  protected Icon   m_icon;
  protected Icon   m_expandedIcon;
  protected Object m_data;
  public IconData(Icon icon, Object data)
    m_icon = icon;
    m_expandedIcon = null;
    m_data = data;
  public IconData(Icon icon, Icon expandedIcon, Object data)
    m_icon = icon;
    m_expandedIcon = expandedIcon;
    m_data = data;
  public Icon getIcon()
    return m_icon;
  public Icon getExpandedIcon()
    return m_expandedIcon!=null ? m_expandedIcon : m_icon;
  public Object getObject()
    return m_data;
  public String toString()
    return m_data.toString();
class FileNode
  protected File m_file;
  public FileNode(File file)
    m_file = file;
  public File getFile()
    return m_file;
  public String toString()
    return m_file.getName().length() > 0 ? m_file.getName() :
      m_file.getPath();
  public boolean expand(DefaultMutableTreeNode parent)
    DefaultMutableTreeNode flag =
      (DefaultMutableTreeNode)parent.getFirstChild();
    if (flag==null)    // No flag
      return false;
    Object obj = flag.getUserObject();
    if (!(obj instanceof Boolean))
      return false;      // Already expanded
    parent.removeAllChildren();  // Remove Flag
    File[] files = listFiles();
    if (files == null)
      return true;
    Vector v = new Vector();
    for (int k=0; k<files.length; k++)
               /*File child = new File(dir, list);
          String name = (child.getName()) ;
          if(child.isDirectory()) add(new Node(child));
          else add(new Node(child));*/
File f = files[k];
if (!(f.isDirectory()))
continue;
FileNode newNode = new FileNode(f);
boolean isAdded = false;
for (int i=0; i<v.size(); i++)
FileNode nd = (FileNode)v.elementAt(i);
if (newNode.compareTo(nd) < 0)
v.insertElementAt(newNode, i);
isAdded = true;
break;
if (!isAdded)
v.addElement(newNode);
for (int i=0; i<v.size(); i++)
FileNode nd = (FileNode)v.elementAt(i);
IconData idata = new IconData(FileTree1.ICON_FOLDER,
FileTree1.ICON_EXPANDEDFOLDER, nd);
DefaultMutableTreeNode node = new
DefaultMutableTreeNode(idata);
parent.add(node);
if (nd.hasSubDirs())
node.add(new DefaultMutableTreeNode(
new Boolean(true) ));
return true;
public boolean hasSubDirs()
File[] files = listFiles();
if (files == null)
return false;
for (int k=0; k<files.length; k++)
if (files[k].isDirectory())
return true;
return false;
public int compareTo(FileNode toCompare)
return m_file.getName().compareToIgnoreCase(
toCompare.m_file.getName() );
protected File[] listFiles()
if (!m_file.isDirectory())
          return m_file.listFiles();
     try
return m_file.listFiles();
catch (Exception ex)
JOptionPane.showMessageDialog(null,
"Error reading directory "+m_file.getAbsolutePath(),
"Warning", JOptionPane.WARNING_MESSAGE);
return null;
Thanks in advance
raja

This code shows the files in your tree
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.*;
public class FileTree1
  extends JFrame
  public static final ImageIcon ICON_COMPUTER =
    new ImageIcon("computer.gif");
  public static final ImageIcon ICON_DISK =
    new ImageIcon("disk.gif");
  public static final ImageIcon ICON_FOLDER =
    new ImageIcon("folder.gif");
  public static final ImageIcon ICON_EXPANDEDFOLDER =
    new ImageIcon("expandedfolder.gif");
  protected JTree  m_tree;
  protected DefaultTreeModel m_model;
  protected JTextField m_display;
  public FileTree1()
    super("Directories Tree");
    setSize(400, 300);
    DefaultMutableTreeNode top = new DefaultMutableTreeNode(
      new IconData(ICON_COMPUTER, null, "Computer"));
    DefaultMutableTreeNode node;
    File[] roots = File.listRoots();
    for (int k=0; k<roots.length; k++)
      node = new DefaultMutableTreeNode(new IconData(ICON_DISK,
        null, new FileNode(roots[k])));
      top.add(node);
                        node.add( new DefaultMutableTreeNode(new Boolean(true)));
    m_model = new DefaultTreeModel(top);
    m_tree = new JTree(m_model);
                m_tree.putClientProperty("JTree.lineStyle", "Angled");
    TreeCellRenderer renderer = new
      IconCellRenderer();
    m_tree.setCellRenderer(renderer);
    m_tree.addTreeExpansionListener(new
      DirExpansionListener());
    m_tree.addTreeSelectionListener(new
      DirSelectionListener());
    m_tree.getSelectionModel().setSelectionMode(
      TreeSelectionModel.SINGLE_TREE_SELECTION);
    m_tree.setShowsRootHandles(true);
    m_tree.setEditable(false);
    JScrollPane s = new JScrollPane();
    s.getViewport().add(m_tree);
    getContentPane().add(s, BorderLayout.CENTER);
    m_display = new JTextField();
    m_display.setEditable(false);
    getContentPane().add(m_display, BorderLayout.NORTH);
    WindowListener wndCloser = new WindowAdapter()
      public void windowClosing(WindowEvent e)
        System.exit(0);
    addWindowListener(wndCloser);
    setVisible(true);
  DefaultMutableTreeNode getTreeNode(TreePath path)
    return (DefaultMutableTreeNode)(path.getLastPathComponent());
  FileNode getFileNode(DefaultMutableTreeNode node)
    if (node == null)
      return null;
    Object obj = node.getUserObject();
    if (obj instanceof IconData)
      obj = ((IconData)obj).getObject();
    if (obj instanceof FileNode)
      return (FileNode)obj;
    else
      return null;
    // Make sure expansion is threaded and updating the tree model
    // only occurs within the event dispatching thread.
    class DirExpansionListener implements TreeExpansionListener
        public void treeExpanded(TreeExpansionEvent event)
            final DefaultMutableTreeNode node = getTreeNode(
                event.getPath());
            final FileNode fnode = getFileNode(node);
            Thread runner = new Thread()
              public void run()
                if (fnode != null && fnode.expand(node))
                  Runnable runnable = new Runnable()
                    public void run()
                       m_model.reload(node);
                  SwingUtilities.invokeLater(runnable);
            runner.start();
        public void treeCollapsed(TreeExpansionEvent event) {}
  class DirSelectionListener
    implements TreeSelectionListener
    public void valueChanged(TreeSelectionEvent event)
      DefaultMutableTreeNode node = getTreeNode(
        event.getPath());
      FileNode fnode = getFileNode(node);
      if (fnode != null)
        m_display.setText(fnode.getFile().
          getAbsolutePath());
      else
        m_display.setText("");
  public static void main(String argv[])
    new FileTree1();
class IconCellRenderer
  extends    JLabel
  implements TreeCellRenderer
  protected Color m_textSelectionColor;
  protected Color m_textNonSelectionColor;
  protected Color m_bkSelectionColor;
  protected Color m_bkNonSelectionColor;
  protected Color m_borderSelectionColor;
  protected boolean m_selected;
  public IconCellRenderer()
    super();
    m_textSelectionColor = UIManager.getColor(
      "Tree.selectionForeground");
    m_textNonSelectionColor = UIManager.getColor(
      "Tree.textForeground");
    m_bkSelectionColor = UIManager.getColor(
      "Tree.selectionBackground");
    m_bkNonSelectionColor = UIManager.getColor(
      "Tree.textBackground");
    m_borderSelectionColor = UIManager.getColor(
      "Tree.selectionBorderColor");
    setOpaque(false);
  public Component getTreeCellRendererComponent(JTree tree,
    Object value, boolean sel, boolean expanded, boolean leaf,
    int row, boolean hasFocus)
    DefaultMutableTreeNode node =
      (DefaultMutableTreeNode)value;
    Object obj = node.getUserObject();
    setText(obj.toString());
                if (obj instanceof Boolean)
                  setText("Retrieving data...");
    if (obj instanceof IconData)
      IconData idata = (IconData)obj;
      if (expanded)
        setIcon(idata.getExpandedIcon());
      else
        setIcon(idata.getIcon());
    else
      setIcon(null);
    setFont(tree.getFont());
    setForeground(sel ? m_textSelectionColor :
      m_textNonSelectionColor);
    setBackground(sel ? m_bkSelectionColor :
      m_bkNonSelectionColor);
    m_selected = sel;
    return this;
  public void paintComponent(Graphics g)
    Color bColor = getBackground();
    Icon icon = getIcon();
    g.setColor(bColor);
    int offset = 0;
    if(icon != null && getText() != null)
      offset = (icon.getIconWidth() + getIconTextGap());
    g.fillRect(offset, 0, getWidth() - 1 - offset,
      getHeight() - 1);
    if (m_selected)
      g.setColor(m_borderSelectionColor);
      g.drawRect(offset, 0, getWidth()-1-offset, getHeight()-1);
    super.paintComponent(g);
class IconData
  protected Icon   m_icon;
  protected Icon   m_expandedIcon;
  protected Object m_data;
  public IconData(Icon icon, Object data)
    m_icon = icon;
    m_expandedIcon = null;
    m_data = data;
  public IconData(Icon icon, Icon expandedIcon, Object data)
    m_icon = icon;
    m_expandedIcon = expandedIcon;
    m_data = data;
  public Icon getIcon()
    return m_icon;
  public Icon getExpandedIcon()
    return m_expandedIcon!=null ? m_expandedIcon : m_icon;
  public Object getObject()
    return m_data;
  public String toString()
    return m_data.toString();
class FileNode
  protected File m_file;
  public FileNode(File file)
    m_file = file;
  public File getFile()
    return m_file;
  public String toString()
    return m_file.getName().length() > 0 ? m_file.getName() :
      m_file.getPath();
  public boolean expand(DefaultMutableTreeNode parent)
    DefaultMutableTreeNode flag =
      (DefaultMutableTreeNode)parent.getFirstChild();
    if (flag==null)    // No flag
      return false;
    Object obj = flag.getUserObject();
    if (!(obj instanceof Boolean))
      return false;      // Already expanded
    parent.removeAllChildren();  // Remove Flag
    File[] files = listFiles();
    if (files == null)
      return true;
    Vector v = new Vector();
    for (int k=0; k<files.length; k++)
               File child = new File(dir, list);
          String name = (child.getName()) ;
          if(child.isDirectory()) add(new Node(child));
          else add(new Node(child));
File f = files[k];
/* if (!(f.isDirectory()))
continue; */
FileNode newNode = new FileNode(f);
boolean isAdded = false;
for (int i=0; i><v.size(); i++)
FileNode nd = (FileNode)v.elementAt(i);
if (newNode.compareTo(nd) >< 0)
v.insertElementAt(newNode, i);
isAdded = true;
break;
if (!isAdded)
v.addElement(newNode);
for (int i=0; i<v.size(); i++)
FileNode nd = (FileNode)v.elementAt(i);
IconData idata = new IconData(FileTree1.ICON_FOLDER,
FileTree1.ICON_EXPANDEDFOLDER, nd);
DefaultMutableTreeNode node = new
DefaultMutableTreeNode(idata);
parent.add(node);
if (nd.hasSubDirs())
node.add(new DefaultMutableTreeNode(
new Boolean(true) ));
return true;
public boolean hasSubDirs()
File[] files = listFiles();
if (files == null)
return false;
for (int k=0; k><files.length; k++)
if (true)
return true;
return false;
public int compareTo(FileNode toCompare)
return m_file.getName().compareToIgnoreCase(
toCompare.m_file.getName() );
protected File[] listFiles()
if (!m_file.isDirectory())
          return m_file.listFiles();
     try
return m_file.listFiles();
catch (Exception ex)
JOptionPane.showMessageDialog(null,
"Error reading directory "+m_file.getAbsolutePath(),
"Warning", JOptionPane.WARNING_MESSAGE);
return null;

Similar Messages

  • How to display an xml file as a tree in html

    Hi, JAVA/XML/XSLT/HTML gurus,
    I have an xml file and want to display it as a tree in html using XSLT.
    Is there any example for this?
    King regards,
    AG

    ... except for the "using XSLT" part. But that doesn't make sense anyway because XSLT doesn't display anything, it just transforms data.

  • My whole document comes out as low res when I export to PDF, even the indesign file also now low res. Tried changing display performance, but that's not helping.

    My whole document comes out as low res when I export to PDF, even the indesign file also now low res. Tried changing display performance, but that's not helping.

    Are your  links up to date? What settings did you use?

  • Display File System With JTree

    Greeting,
    Are there any suggestions or example which is about displaying file system with JTree??
    Thx Advanced

    Just create tree model from your filesystem.
    If you like to have fancier look, you may also
    create renderer which would show
    appropriate icons.
    Look to classes
    DefaultMutableTreeNode
    DefaultTreeModel
    ( all in the javax.swing.tree )

  • Idoc-xi-file scenario.  how to display file in html format

    I am not sure whether this is a valid question.........but want to confirm as it was asked by somebody
    In idoc-xi-file scenario.......  how to display file in html format ??
    Thanks in advance
    Kumar

    Hi Vijayakumar,
    Thanks for your reply !! You mean to say I got to use XSLT mapping and also .htm and .html extension together to produce the html file ?? or it is sufficient to use any one of them to produce the html file ??
    Regards
    Kumar

  • QuickTime 10.1 does not seem to be compatible with OSX Lion  - clicking on the displayed file window switches to another displayed app, doesn't play or control the video.

    If I open a movie file (appears to be any type - .mov, m4v, mv4) it displays on the desktop, but when clicked, the Mac reverts to another open application (immediately UNDER to point of the mouse click) and not the displayed movie file.  It appears the screen mapping is flawed...
    Anyone else have this problem? (does not appear to be a problem with QT7)  Running OSX Lion 10.7.3 and QT Player 10.1 (501.8) - all most current as far as I can tell...

      Yes, same problem. The active clickable area appears to be shifted down and to the right as if it is the shadow mask (to make it look like layers in the display) that is responding. Means you can't move the control palette to the top of the window (to not block security video with time track at bottom) or even close the window. The X in the bubble appears when moused over but the click goes through it.
      Most obvious if you open more than one movie at a time and they cascade. You can't get at the ones underneath until a few down the stack and it gets an upper wrong one.
      Who's testing these things?
      For comparison testing to recreate problem: Mac Pro (System Information has also been dumbed down from System Profiler, push System Report for the useful stuff) with an ATI Radeon HD 5770 driving two displays.
       Also viewing desktop of another computer on the network is slower and, for instance in World of Warcraft, the hand pointer flickers.
      And finder windows can't be narrowed as much any more to show only a list of file names for drag and drop sorting.
      Was hoping that by 10.7.3, it would be safe to jump, since several posts told me how to Terminal > networksetup -setv6off Ethernet to fix iTunes streaming to expresses and other dumb bugs.

  • Error while displaying file " C:Temp Filename.Ext cannot be created"

    Dear Friends
    Some users face problem while display the file. They get message " C:\Temp\ Filename.Ext cannot be created ". I checked Details. I got explaination as follows.
    Caution! You are not authorized to work with temporary storage
    Message no. ED204
    Diagnosis
    You do not have authorization to read or write from or to the temporary storage.
    The system uses the temporary storage when you display or change programs using the ABAP Editor.
    The system checks to see whether there is a temporary version of the program.
    If there is, a dialog box appears in which you must choose whether to use the temporary version or the database version.
    The system fills the temporary storage when the editor crashes or you save a temporary version of the program.
    System Response
    You probably do not have the authorization object S_DATASET.
    Procedure
    Ask your system administrator to assign you the relevant authorization.*
    Actually this  problem never occurs frequently. User access the files very frequently creating around 200 Mb to 400 Mb in C:\Temp Folder per day per user. I observerd as per message that User is not have Access right to C drive. Once I get access from IT for that user he is able to display file. But before giving right he is able to display file. But suddenly he is not able to display. I am not getting exact reason why this problem occurs. Some users temp folder size is upto 700 Mb with no acces right to C Drive still he is able to see the image.
    In DC20 I have kept C:\Temp as path for temp folder.
    I have checked the links  also
    Request you to provide me
    What is exact reason of the error?
    Is the solution to problem is giving access rights to the user?
    Do I have to give authorization object S_DATASET to a user?
    With Regards
    Mangesh Pande

    Dear Amaresh
    Thanks for your reply and solution.
    So you mean to say thats this Authorization object  has to be provided to user?
    But my question is how the user was able to see the file even when this Authorization Object was not assigned.
    He was able to display all file. But for particular DIR he is not able to display.
    I have checked this thread
    http://wiki.sdn.sap.com/wiki/display/PLM/Error26172withSAPGUI710+patch13.
    User has SAP GUI 7.10
    File Version 7100.1.0.1027
    Build   0
    Patch Level  0
    Request your help
    With Warm Regards
    Mangesh Pande

  • The Video app in OS7 update doesn't display file names.

    The Video app in OS7 doesn't display file names under the image.
    How can I identify my video files without having to open each file to access the file name.
    Is there something I am missing or is this just an omission in the OS7 upgrade.
    I am a music teacher and this lack of file names makes the app virtually useless for use in the classroom.

    Agreed. This has been a problem with TV Shows in the Videos app since forever, but at least it used to put the name under Movies. Now instead fixing it for TV Shows in iOS 7 they've done the opposite and made Movies fail the same way as TV Shows always have!
    Apparently it still lists the title for Home Videos, so the best work around for now is probably to reclassify all your Movies as Home Videos. Sigh.
    Apple's Videos app development team seem to be unaware that iTunes can store and play movies and TV shows that don't come from the iTunes Store, videos that don't have covers, and that need to display the names and other info from iTunes for them. They also seem to not understand that the default grid view for videos is totally inadequate for users with scores or hundreds of movies and TV shows that they home share to their iPads and iPhones from iTunes. The Videos app needs a list view at least, as well as a grid view.
    All they have to do is look at how the Apple TV handles the same files and meta-data from iTunes and provide something similar for the iPad and iPhone. Why after all these years they still don't get that I have no idea.

  • Display files in web browser

    Hi
    I need to be able to display files(doc, pdf, images etc) in the web browser. My purpose here is just to display the file. Can we do it using Linktourl?
    Thanks
    Jay

    Hi
      Check this thread. You will get the required info you need. If you require more clarifications let me know
    Re: Opening documents...
    Also check this thread
    Re: Display File residing on WAS
    Hope that was helpful
    regards
    ravi

  • Displayed DOM on an tree, then how to modify the tree

    Hi,
    This my first time here.
    I have DOM object parsed from xml. I displayed it on a tree using following 2 classes. My question is how do I reload the treeModelAdapter when I update/insert the tree node? How do I implement valueForPathChanged(...) method? My tree didn't updated using the method.
    Note the methods in DefaultTreeModel do not work here.
    public class DomToTreeModelAdapter implements TreeModel{
    Element element;
    public DomToTreeModelAdapter(Element elem) {
    element = elem;
    public Object getRoot() {
    return new AdapterNode(element);
    public void valueForPathChanged(TreePath path, Object newValue) {
    AdapterNode adapter = new AdapterNode(element);
    Object currentNode = path.getLastPathComponent();
    Object parentNode = path.getPathComponent(path.getPathCount()-2);
    int[] index = {getIndexOfChild(parentNode, currentNode)};
    Object[] children = {(Object)newValue};
    TreeModelEvent ev = new TreeModelEvent(adapter, path, index, children);
    fireTreeNodesChanged( ev);
    private Vector listenerList = new Vector();
    public void addTreeModelListener( TreeModelListener listener ) {
    if ( listener != null && ! listenerList.contains( listener ) ) {
    listenerList.addElement( listener );
    public void removeTreeModelListener( TreeModelListener listener ) {
    if ( listener != null ) {
    listenerList.removeElement( listener );
    public void fireTreeNodesChanged( TreeModelEvent e ) {
    Enumeration listeners = listenerList.elements();
    while ( listeners.hasMoreElements() ) {
    TreeModelListener listener = (TreeModelListener) listeners.nextElement();
    listener.treeNodesChanged( e );
    public class AdapterNode {
    Node domNode;
    public AdapterNode(Node node) { 
    domNode = node;
    public String toString() { ...
    public AdapterNode child(int searchIndex) {
    org.w3c.dom.Node node = domNode.getChildNodes().item(searchIndex);
    int elementNodeIndex = 0;
    for (int i=0; i<domNode.getChildNodes().getLength(); i++) {
    node = domNode.getChildNodes().item(i);
    if (node.getNodeType() == ELEMENT_TYPE )
    && elementNodeIndex++ == searchIndex) {
    break;
    return new AdapterNode(node);
    public int index(AdapterNode child) {
    int count = childCount();
    for (int i=0; i<count; i++) {
    AdapterNode n = this.child(i);
    if (child.toString().equalsIgnoreCase(n.toString())) { return i; }
    return -1; // Should never get here.
    I also added listener class:
    public class DomTreeModelListener implements TreeModelListener {
         Element element;
         public DomTreeModelListener(Element elem){
              element = elem;
         public void treeNodesChanged(TreeModelEvent e) {
              //DefaultMutableTreeNode node;
    Object node = e.getTreePath().getLastPathComponent();
    System.out.println("node: " + node);
    try {
    int index = e.getChildIndices()[0];
    System.out.println("index: " + index);
    //node = node.getChildAt(index);
    node = new DomToTreeModelAdapter(element).getChild(node, index);
    } catch (NullPointerException exc) {}
    What is the problem?
    Thank you in advance for any help.

    I ment give us a runnable code that demenstrates your problem, try and duplicate it... Dont post use a 5000line class, just one that shows the problem,
    ie create a new class that just does what your one is supose to with out all the bits and pieces, if if works then work from there, else post that code.
    ps did you also read the code formating tags

  • Display File Extension in iPhoto?

    I've just started to use iphoto.  In the thumbnail view of an event (or for that matter, anytime I'm viewing a display of thumbnails), I would like iphoto to display file name and file extension.  It's not doing that and I can't see a setting in iphoto preferences to enable file extensions.  I know there's a Finder preference to show all extensions, and it is checked.
    Is there a way to display file extensions?

    Yes.
    Using Photoshop or Photoshop Elements as Your Editor of Choice in iPhoto.
    1 - select Photoshop or Photoshop Elememts as your editor of choice in iPhoto's General Preference Section's under the "Edit photo:" menu.
    2 - double click on the thumbnail in iPhoto to open it in Photoshop.  When you're finished editing click on the Save button. If you immediately get the JPEG Options window make your selection (Baseline standard seems to be the most compatible jpeg format) and click on the OK button. Your done. 
    3 - however, if you get the navigation window
    that indicates that  PS wants to save it as a PS formatted file.  You'll need to either select JPEG from the menu and save (top image) or click on the desktop in the Navigation window (bottom image) and save it to the desktop for importing as a new photo.
    This method will let iPhoto know that the photo has been editied and will update the thumbnail file to reflect the edit..
    NOTE: With Photoshop Elements  the Saving File preferences should be configured as shown:
    I also suggest the Maximize PSD File Compatabilty be set to Always.  In PSE’s General preference pane set the Color Picker to Apple as shown:
    Note 1: screenshots are from PSE 10
    Note:  to switch between iPhoto and PS or PSE as the editor of choice Control (right)-click on the thumbnail and select either Edit in iPhoto or Edit in External Editor from the contextual menu. If you use iPhoto to edit more than PSE re-select iPhoto in the iPhoto General preference pane. Then iPhoto will be the default editor and you can use the contextual menu to select PSE for your editor when desired.

  • Finder 600 error/not displaying files

    Finder giving me a 600 error, if it opens it won't display files, especially those on a network hard drive. It will let me see most folders though, again, if I can get past the 600 error. iTunes stopped working for a while but the second I clicked into these forums it worked!
    I've seen some similar threads but they didn't fix my issue. FYI I'm running the latest OS.

    Please read this whole message before doing anything.
    This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
    Step 1
    The purpose of this step is to determine whether the problem is localized to your user account.
    Enable guest logins* and log in as Guest. For instructions, launch the System Preferences application, select Help from the menu bar, and enter “Set up guest users” (without the quotes) in the search box. Don't use the Safari-only “Guest User” login created by “Find My Mac.”
    While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. Same problem?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    *Note: If you’ve activated “Find My Mac” or FileVault, then you can’t enable the Guest account. The “Guest User” login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.
    Step 2
    The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login, or by a peripheral device.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode* and log in to the account with the problem. The instructions provided by Apple are as follows:
    Shut down your computer, wait 30 seconds, and then hold down the shift key while pressing the power button.
    When you see the gray Apple logo, release the shift key.
    If you are prompted to log in, type your password, and then hold down the shift key again as you click Log in.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.  The next normal boot may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    *Note: If FileVault is enabled, or if a firmware password is set, or if the boot volume is a software RAID, you can’t boot in safe mode.
    Test while in safe mode. Same problem?
    After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of steps 1 and 2.

  • Finder in Yosemite does not display files

    since i upgraded to Yosemite i have been having a problem with finder displaying files.  if i save a new file to my desktop it does not display until i logout and log back in.  when i open any folder other than my desktop nothing is displayed.  i just get a spinning wheel in the bottom right corner.  if i list the folder in terminal all the files are displayed.  i did not have any these issues with mavericks.
    iMac (27-inch, Mid 2011)
    3.4 GHz Intel Core i7
    16 GB 1333 MHz DDR3
    AMD Radeon HD 6970M 1024 MB

    I'm getting the same result - both with 10.10 and with 10.10.1 Beta.   The finder will display the main HD root, but nothing under it - except the Desktop.  New files on the desktop require a log out-in cycle to appear.
    Other apps that normaly have file system access also will not show second level files.  Launchpad only shows "Loading Applications", so it looks to also not be able to access the apps directory.
    Other drives do not have this problem - only the main system HD. 
    The dock also seems to lock up quite often... 
    MacBook Pro (17-inch, Mid 2009)
    2.8 GHz Intel Core 2 Duo
    8 GB 1067 MHz DDR3
    NVIDIA GeForce 9400M 256 MB

  • Maximum number displayed files in Folder in Dock?

    One of our users has over 800 files saved directly in her Documents folder. We keep this folder in the usual location, and also have it displayed in the Dock as a "list". When she clicks on the folder, about the first half of the files show up - if displayed alphabetically for example, she gets A - M.
    Does anyone know if this is fixable? I'm assuming here that there is some maximum number of displayed files which maybe I can fix by editing a .plist or something. It drives her nuts to have to do the "open in Finder" thing half the time, but not the other half of the time (obviously, when she opens this folder as a Finder window everything is there, it is only the display in the Dock which refuses to show all items).
    Thanks!

    Thanks for the info. There is indeed a maximum number of files that the dock will show in the contextual menu. Yeah, it would be best if the user wouldn't keep everything organized like that, but it isn't possible to lean over someone's shoulder all the time...

  • How to display file extensions

    Hi,
    I'm trying to get our Sharepoint 2013 server to show file extensions again and I've had no luck so far. I've been able to add an extra name column that shows the file extension (like ), but that name is not clickable anymore so I've ended up with one name
    that's a link and the same name next to it. This doesn't look good, especially when the users pick overly long file names.
    This (http://social.technet.microsoft.com/wiki/contents/articles/11161.how-to-display-file-extensions-in-a-sharepoint-document-library.aspx) seems to apply to Sharepoint 2007 only. I'm not sure which onet.xml file they mean and the default file has several
    occurences of "Name=”Created_x0020_Date”", or how adding
    Name=”File_x0020_Type”/> without an extra opening bracket would work.
    I've also found and tried this solution: http://social.technet.microsoft.com/Forums/sharepoint/en-US/59c15eee-9116-4aa1-8d16-32cd361c9a2f/show-file-extensions-in-document-library?forum=sharepointcustomizationprevious
    >>3. Edit the WebPartPages:XsltListViewWebPart so that the link contains the extension.
    >>a. Open SharePoint Designer and click on the desired document library.
    >>b. Open the View you want to change, which in most cases is "All Documents".
    >>c. Find the line that looks like this:
    >><xsl:value-of select="$thisNode/@FileLeafRef.Name" />
    >>d. Edit the line to look like this:  (the xsl:if tests to see if the suffix is not blank and then displays a '.' and the suffix)
    >><xsl:value-of select="$thisNode/@FileLeafRef.Name" /><xsl:if test="$thisNode/@FileLeafRef.Suffix!=''">.<xsl:value-of select="$thisNode/@FileLeafRef.Suffix" /></xsl:if>
    This doesn't seem to work with Sharepoint 2013 because the line <xsl:value-of select="$thisNode/@FileLeafRef.Name" /> doesn't seem to exist. Are there any other suggestions on how to get the file extensions to show?
    Thank you.

    Hi
    use these functions
    RIGHT (Text, Number)
    Return X characters from the right
    RIGHT(“The Quick Brown Fox”, 5)
    n
    SEARCH(Text1, Text2, Num)
    Returns the index of Text1 within Text2,starting the search at index Number
    Formula should be
    right([Name-column],search[".",[Name-column],1))
    More info regarding calculated columns
    http://junestime.wordpress.com/2013/02/12/sharepoint-calculated-column-formulas/
    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

Maybe you are looking for

  • How can I buy more storage for Elements?

    Looking how to upgrade storage for my Photoshop Elements account. Every time I click on upgrade I'm taken to my products page and can't do anything from there as there are no active links to upgrade, buy more storage. I keep looping from the control

  • Cash Account Determination !!

    Hi Gurus !! I am trying  to configure the Cash Account Determination (OV77). By default there are two accesses defined for the condition type CASH one is against the Sales Organistion and the other is for the Sales Area. I defined my own table with t

  • ZIP attachments in PDF file

    How can ZIP files be opened from a PDF file using Preview. First, how can you see attachments within Preview, and then, how can it be opened.

  • ITunes 9 won't switch stores

    Hello I am using iTunes 9 and am trying to switch to different countries and doesn't work. It just keeps timing out after trying for a few seconds. I tried on a Mac and on a PC. Neither switches stores. Does anyone else have this problem?

  • Which encryption for the remote control of zenwork use?

    Which encryption for the remote control of zenwork use?