How to force JTree to not display  the leaves

Hi
Is there anyway to force JTree to not display the "end nodes" so to speak.
What I want is that if a node is a leaf and is not allowed to have children
I do not want the JTree to display them.
I need this to build a component for a custom file system view like Windows Explorer
which contains a tree with folders on the left and and contents of the currently selected( expanded)
folder on the right. But Explorer does not display any files in the left pane, only folders.
So I need to implement the same in my component

This will give you some things to think aboutimport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.*;
import java.util.*;
public class Test3 extends JFrame {
  Vector nodes = new Vector();
  DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
  DefaultTreeModel dtm = new DefaultTreeModel(root);
  JTree jt = new JTree(dtm);
  JCheckBox jcb = new JCheckBox("Allow Expansion");
  Random r = new Random();
  int nodeCount=0;
  public Test3() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = getContentPane();
    addNodes(root,0);
    content.add(jcb, BorderLayout.NORTH);
    content.add(new JScrollPane(jt), BorderLayout.CENTER);
    jt.addTreeWillExpandListener(new TreeWillExpandListener() {
      public void treeWillCollapse(TreeExpansionEvent tse) {}
      public void treeWillExpand(TreeExpansionEvent tse) throws ExpandVetoException{
        if (jcb.isSelected()) return;
        TreeNode tn = (TreeNode)tse.getPath().getLastPathComponent();
        Enumeration e = tn.children();
        boolean expand = false;
        while (!expand && e.hasMoreElements()) {
          if (((TreeNode)e.nextElement()).getChildCount()!=0) expand  = true;
        if (!expand) throw new ExpandVetoException(tse);
    setSize(400, 400);
  private void addNodes(DefaultMutableTreeNode parent, int level) {
    int cnt = r.nextInt(3)+3-level;
    for (int i=0; i<cnt; i++) {
      DefaultMutableTreeNode node = new DefaultMutableTreeNode("Node"+nodeCount++);
      parent.add(node);
      nodes.add(node);
      addNodes(node, level+1);
  public static void main(String[] args) { new Test3().setVisible(true); }
}

Similar Messages

  • HT2500 How do I not display the preview pane in mail until I open it with a double click? Some mail I do not wish to open-just delete it.

    How do I not display the preview pane in mail until I open it with a double click? Some mail I do not wish to open-just delete it. New macbook pro with LION OS

    Just drag the divider line between the preview pane and the message list all the way to the edge so the preview is completely closed. Selected messages will open in a new window with a double-click or the return key.

  • How do I connect to Time Capsule from a Windows 8.1 machine which is on a Windows domain. I have been able to connect from a Windows 7 machine on a Windows domain to a Time Capsule. Airport utility is not displaying the Time Capsule Win8.1 machine

    How do I connect to Time Capsule from a Windows 8.1 machine which is on a Windows domain. I have been able to connect from a Windows 7 machine on a Windows domain to a Time Capsule. Airport utility is not displaying the Time Capsule Win8.1 machine.
    I have checked that the firmware has been updated to 7.6.4 . Similalrly the Win8.1 machine has been loaded with the update specified in another discussion.

    Firstly how are you connecting to the TC.. wireless or ethernet?
    Please open a command window and ping it.. ping by name and by IP address.
    If ping succeeds at least by IP it should work.
    In windows explorer type
    \\10.0.1.1 (or whatever the TC ip is.. that is the default).
    Having the airport utility for windows loaded can help the process. As it loads bonjour for windows.
    7.6.4 firmware on the TC is useless. It works better on 7.6.1
    If the ping does not succeed by either name or IP address yet you have internet through the TC, then your network is setup wrongly. You are have firewalls blocking local IP. Take down all the firewalls.

  • Firefox does not display the basic menu line File Edit View etc. How do I get this menu to show. I have tried uninstalling and reinstalling, but that does not help

    When I ask for help finding bookmarks, the answer tells me to click on bookmarks as shown in the illustration, but there is no such line displayed on my computer.

    '''''"Firefox does not display the basic menu line File Edit View etc."''''': That is the Menu Bar; see below.
    '''<u>Menu Bar</u>''' (File, Edit, View, History, Bookmarks, Tools, Help)<br /> <u>Firefox 3.6.x versions allow the user to hide the Menu Bar.</u><br />
    *Tap the ALT key or the F10 key, Menu Bar will display, click View, click Toolbars, click Menu Bar to place a check mark next to it, '''''OR'''''
    *Press and hold the ALT key while pressing the letters VTM on your keyboard, then release the ALT key
    *See: http://support.mozilla.com/en-US/kb/Menu+bar+is+missing
    '''<u>Other Toolbars</u>''', see: https://support.mozilla.com/en-US/kb/Back+and+forward+or+other+toolbar+items+are+missing<br />
    '''<u>Status Bar</u>''': click View, click Status Bar to place a check mark<br />
    '''<u>Full Screen Mode</u>''': If you have no Toolbars or Tab Bar: Press F11 (F11 is an on/off toggle). See: http://kb.mozillazine.org/Netbooks#Full_screen<br />
    Also see: http://kb.mozillazine.org/Toolbar_customization_-_Firefox#Restoring_missing_menu_or_other_toolbars
    <br />
    <br />
    '''Other items that need your attention'''
    The information submitted with your question indicates that you have out of date plugins with known security and stability issues that should be updated. To see the plugins submitted with your question, click "More system details..." to the right of your original question post. You can also see your plugins from the Firefox menu, Tools > Add-ons > Plugins.<br />
    <br />
    *Adobe PDF Plug-In For Firefox and Netscape
    **Current versions are 9.4.2 and 10.0.1 (aka Reader X)
    **More info about version 10 (aka Reader X)
    ***New Adobe Reader X (version 10) with Protected Mode was released 2010-11-19
    ***See: http://www.securityweek.com/adobe-releases-acrobat-reader-x-protected-mode
    #'''Check your plugin versions''': http://www.mozilla.com/en-US/plugincheck/
    #*'''Note: plugin check page does not have information on all plugin versions'''
    #'''Update Adobe Reader (PDF plugin):'''
    #*From within your existing Adobe Reader ('''<u>if you have it already installed</u>'''):
    #**Open the Adobe Reader program from your Programs list
    #**Click Help > Check for Updates
    #**Follow the prompts for updating
    #**If this method works for you, skip the "Download complete installer" section below and proceed to "After the installation" below
    #*Download complete installer ('''if you do <u>NOT</u> have Adobe Reader installed'''):
    #**Use the links below to avoid getting the troublesome "getplus" Adobe Download Manager and other "extras" you may not want
    #**Use Firefox to download and SAVE the installer to your hard drive from the appropriate link below
    #**Click "Save to File"; save to your Desktop (so you can find it)
    #**After download completes, close Firefox
    #**Click the installer you just downloaded and allow the install to continue
    #***Note: Vista and Win7 users may need to right-click the installer and choose "Run as Administrator"
    #**'''<u>Download link</u>''': ftp://ftp.adobe.com/pub/adobe/reader/
    #***Choose your OS
    #***Choose the latest #.x version (example 9.x, for version 9)
    #***Choose the highest number version listed
    #****NOTE: 10.x is the new Adobe Reader X (Windows and Mac only as of this posting)
    #***Choose your language
    #***Download the file, SAVE it to your hard drive, when complete, close Firefox, click on the installer you just downloaded and let it install.
    #***Windows: choose the .exe file; Mac: choose the .dmg file
    #*Using either of the links below will force you to install the "getPlus" Adobe Download Manager. Also be sure to uncheck the McAfee Scanner if you do not want the link forcibly installed on your desktop
    #**''<u>Also see Download link</u>''': http://get.adobe.com/reader/otherversions/
    #**Also see: https://support.mozilla.com/en-US/kb/Using+the+Adobe+Reader+plugin+with+Firefox (do not use the link on this page for downloading; you may get the troublesome "getplus" Adobe Download Manager (Adobe DLM) and other "extras")
    #*After the installation, start Firefox and check your version again.

  • HT3529 My iphone4s is not displaying the contact name of other iphone users in the SMS folder, anyone know how to sove this  problem?

    My iphone4s is not displaying the contact name of other iphone users in the SMS folder, anyone know how to sove this  problem?

    You can contact iTunes support via this page : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • How to not display the messageField in an IconItemRenderer

    Hello,
    how to not display the messageField in an IconItemRenderer, just display labelField and icon.
    Thanks

    If you're using JavaFX 8 you can use the following in an external style sheet:
    .table-view .column-header-background {
      -fx-pref-height : 0 ;
    If you're using JavaFX 2.2, the -fx-pref-height attribute is not available in css, so I think you have to resort to a lookup:
    final Region tableHeader = (Region)table.lookup(".column-header-background");
        tableHeader.setPrefHeight(0);
    As always, I feel obliged to point out that I don't really like lookups. Sometimes they seem to be the only way, though.

  • How do i type in tamil in microsoft office for mac? my previous tamil documents from my pc are not displaying the font correctly, nor am i able to use the inbuilt mac tamil font to write in microsoft office

    How do i type in tamil in microsoft office for mac? my previous tamil documents from my pc are not displaying the font correctly, nor am i able to use the inbuilt mac tamil font to write in microsoft office

    You should probalby post your question on Microsoft's own forums for their Mac software since it's their stuff you're asking about:
    http://answers.microsoft.com/en-us/mac

  • How to not display the error message ?

    hi everybody,
    I would like to know if it is possible to not display the error message in BO XI R2 when I try to refresh my reports ?
    (like "the query bla bla does not fetch any data...")
    Thanks for your help,
    Mario

    I've found this method to not display this error message but  the problem is that the prompt message when you refresh the report are not displayed:
    Has someone an idea ?
    Private Sub Document_BeforeRefresh(Cancel As Boolean)
    Application.Interactive = False
    End Sub
    Private Sub Document_AfterRefresh()
    Application.Interactive = True
    End Sub
    Edited by: Pascolo Mario on Oct 22, 2008 4:35 PM

  • How can I get iTunes to display the tracks from a CD in their original (album) order?

    To be absolutely honest, I don't really understand what this box is for, so I shall just use it to repeat and expand on my question. (I have already sent a "Feedback" comment on the same topic).
    How can I get iTunes to display the tracks from a CD in their original (album) order?
    It seems to me that there is something very basic wrong with the way iTunes handles CD Tracks.
    Professionally produced CD tracks are seldom if ever in a randomised order. Why then does iTunes seem unable to display the tracks in the order they appear on the original CD source - whether from a personally owned CD or from a download from the iTunes Store?
    Some music demands a specific, non-alphabetic sequence in order to make sense. Why does it seem that iTunes only offers Alphabetic, or reverse alphabetic order - both of which make a nonsense of the original, often intended order of tracks?
    Why not replace the so-called "cover-art" in the bottom left hand corner if the iTunes window - which, while it may look attractive to some, gives the barest of information concerning the original disc, with a list of the original CD tracks in their original order, so that the user can easily reestablish the order in which they should be played.
    As I would expect legibility might be a problem with doing this, why could not the original contents, (in their original order), at least, be displayed when the "cover art" is double clicked-on - the result of which at present gives me an enlarged version of the "Cover Art". While on the subject of the contents of the source disc, what about all the album notes which someone takes trouble to write in order to increase the appreciation of the music on the CD and the listener's general background knowledge of the artists involved. Such notes, it seems to me, have considerable intrinsic value in their own account. I would, I think, normally be prepared to buy such "Sleeve notes" - so long as a "taster" was supplied (as it is for the music) - for something like the cost of a single 'Tune" on iTunes.
    These two aspects let Apple iTunes down enormously, in my opinion. I think that by chopping even quite protracted sequences of music up into bits does no one any favours - except perhaps Apple's already quite substantial bank balance. People have to be aware that two and a half, to three and a half minutes is a very short time to develop a piece of worthwhile music, and that there are many, many composers, not all of whom are alive today who have written music that huge masses of mankind value for the enrichment of their lives and the human condition in general.
    Please make the viewing of iTunes tracks in their correct order by default possible. By all means have the alphabetical variations available as offering a different approach to the music, but not the sole approach to it - PLEASE.
    Frustratedly yours
    Alan Whitaker
    PS I work at my old 24" iMac Intel Core 2 machine which runs OS "Tiger" - because it is more beautiful to look at, the screen is more pleasant to work on, and because, in some ways it is more capable (it will run FreeHand MX without needing a "patch"), than my more recent 21.5" which runs "Snow Leopard". (I don't find it that much slower, either).

    Dear Mike
    Thanks for the support. I am utterly amazed that after all the hype about how good iTunes is that it cannot play a downloaded CD in the correct order, and that what that order should be is not available directly from within one's own iTunes installation. (I know that one can go back to the iTunes Store to check what the order should be, but having downloaded the tracks surely iTunes is clever enough to retrieve this important information.
    My iTunes to differ from yours in that I have also noticed that it seems unable to download copies of my "talking books" in the correct order either. But in my case it downloads them - from a CD - in order, but with the first track downloaded first - so that it appears at the bottom of the column of tracks so that it would get played last! (At least this is, while being inexplicable, a relatively "logical" bit of blundering and because of this is relatively easy to put right!).
    I like many genres of music, some of which are not really programmed except perhaps by the artist performing them. I know that Frank Sinatra was very careful to programme his album songs to obtain a particular effect and in relation to the keys of the music. iTunes presumes to know better.
    Film scores may be totally randomly put together, in some cases, but in others the order is vital to one's appreciation of the music as a whole and how it relates to the plot of the film.
    In symphonic music most works are divided into sections and are conceived by the composer that way. Some individual sections may gain a life of their own if played separately, but they are never complete in the sense that the composer envisaged them without being placed in their proper context.
    Opera and probably most choral music too, is similar except that the words may well become meaningless if the order is changed at the whim of a piece of ill-written computer code, while ballet music has to be heard totally within its sequential context or it becomes meaningless.
    Finally, I would venture that iTunes, by jumbling up the order of the tracks as recorded on a CD, does an immense disservice, not only to the music on a particular CD, but to music in general, by expressing everything in terms of "Songs" - which it seems to interpret as stand-alone items of between 2 and 4 minutes whatever the genre. Even the way the iTunes publicity speaks of how many "songs" it can store instead of how many minutes or hours of recorded sound. This has to be another brick in the wall of "dumming-down" of people's expectations, and the shortening of their attention spans.
    I don't know about anyone else, but I feel betrayed by Apple over this. Perhaps the look, feel and general presentation of an item are not the most desirable features of a consumer product. Maybe it should be judged more on it fitness for the purpose for which it was sold. There is one other possibility - that Apple are trying to redefine "Music" - and that everything that lasts longer than about 3.5 minutes or is in the form of what could for want of a better term be called symphonic in the broadest sense is something else - not "Music" within Apple's new definition, at all!
    Well that's off my chest! now I can get down to creating some sort of order in my iTunes Libraries, knowing that I have to reconsult all the sources in order to confirm the source playing order.
    Anyway thanks again. At least I know that it is not just me
    alanfromthatcham

  • I have installed iOS7 on my iPhone4. I am able to add/edit contacts by clicking the "contact" icon. But when I am trying to do the same after clicking the "phone" icon, it is not displaying the keypad. I believe it is a bug in iOS7. Please confirm. iPhone

    I have installed iOS7 on my iPhone4. I am able to add/edit contacts by clicking the "contact" icon. But when I am trying to do the same after clicking the "phone" icon, it is not displaying the keypad. I believe it is a bug in iOS7.
    Please confirm.
    iPhone 4, iOS 7

    Hello jayanand,
    You may need to force close all open apps, then restart the phone. If necessary, you may need to reset the phone after that.
    iOS: Force an app to close
    http://support.apple.com/kb/HT5137
    iPhone, iPad, iPod touch: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/HT1430
    Cheers,
    Allen

  • App Store shows update available but will not display the update or tell me that there are no updates...

    There is a badge with the number 1 on my "App Store" icon, but when I go to see what needs to be updated, the App Store does not display the app that has an update nor does it say that there are no updates available.  Basically the place that tells me these things, is completely blank.  I have the word "Updates" at the top of the screen and I can see an icon on the bottom right corner area that has the cirlce with a down arrow and the word "Updates" with a badge with the number 1 in it. 
    The iPad 2 has 6.1.2 for the iOS.  I have already closed the app out completely by closing the app in the multitasking section and then restarting it.  This does not correct the issue.  I have also restarted the iPad 2, however this did not correct the issue either.
    If anyone has seen this and knows it is a glitch in the software, and that Apple is aware of it, please let me know.  If anyone knows how to correct this, please let me know.  Thanks.

    The update server is down; try this temporary workaround
    App Store>Purchased>Select "All"
    Note: Look out for apps that have the word "Update"
    http://i1224.photobucket.com/albums/ee374/Diavonex/9c256282736869f322d4b3071bbb2 a82_zps51a6f546.jpg

  • My IPhone 4's mailing feature does not display the toolbar at the bottom for deleting, moving, or writing emails. What is wrong with it?

    My work recently decided to buy every full time employee an IPhone 4 to be used for work purposes. (I do suspect these are refurbished, but I don't think that matters) I have had no trouble with it, except for on occasion the mailing feature does not display the toolbar at the bottom for deleting, moving, or writing emails. You know what I'm talking about...that bar at the bottom of the mailbox when you open an email that you use to delete, respond, forward, move, etc. It just goes away for no reason, and then reappears for a day or two, and goes away again. It is quite annoying since I can't respond to any of my emails without getting on my work computer. If you have any suggestions, please help!

    Hi there,
    You may need to force close the Mail application when this happens. The next time this happens, use the steps in the article below to coles out of the mail application.
    iOS: Force an app to close
    http://support.apple.com/kb/ht5137
    Hope that helps,
    - Griff W.

  • The Sequence in Premiere not display the video channels

    I have this problema: The Sequence panel NOT display the video channels, only the audio cannel.  This occur in an old Project. When I start a new Project there is no problem, the sequence show all video and audio channels. How can I fix it ?  Muchas gracias por su cooperación!!

    Maybe try importing the old project into a new one, instead of just opening the old project.

  • When my Firefox language settings are fr_fr or fr_ca Firefox does not display the e with acute accent character correctly when it is displayed in a javascript alert box. However, it does display it correctly when my language settings are just fr. Please t

    Firefox does not display the e with acute accent character correctly from a javascript alert box when my browser language settings are fr_ca or fr_fr. However, it does it correctly when my browser language setting is fr. How do i get it to display e with acute accent and other iso8859 characters correctly in a javascript alert box when my browser language settings are fr_fr and fr_ca?
    == This happened ==
    Every time Firefox opened

    Use Unicode (UTF-8) for those characters.
    Then you will always be sure that they are displayed correctly.

  • Windows could not display the images available for installation

    I am trying to perform unattended installation of windows which I created with Windows AIK. When I add answer file on USB's with windows installation root I get "windows could not display..." message. Problem is there even when there are just a
    few simple lines (oobe, microsoft international core-WinPe).
    I replaced install.wim file of standard windows installation iso with customized install.wim and then created catalog file with windows system image manager.
    Kind people of world, please help!

    Hi bugili,
    Could you help us post the complete error information, it will more helpful when we locate the issue. I am not quite understand “add answer file on USB's with windows
    installation root”, do you mean the answer file and install file on the external device? Please try to confirm this image has the same Security permission with
     others image in WDS image share folder,  the WDS default image location is like
    x:\RemoteInstall\Images.
    If it not work please post the WDS error log,
    How to enable logging in Windows Deployment Services (WDS) in Windows Server 2003, Windows Server 2008, Windows Server 2008 R2, and in Windows Server 2012
    http://support.microsoft.com/kb/936625/en-us
    The simlar thread:
    Windows could not display the images available for installation.
    https://social.technet.microsoft.com/Forums/windowsserver/en-US/07fe03dd-9798-4583-8d0b-dc963c95434c/windows-could-not-display-the-images-available-for-installation?forum=winserversetupMore
    information:
    How to Add a Boot Image to WDS Server
    https://social.technet.microsoft.com/wiki/contents/articles/11643.how-to-add-a-boot-image-to-wds-server.aspx
    I’m glad to be of help to you!
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

Maybe you are looking for

  • Report printout

    hi i ve a button on form named print. i want to print report by clicking on this button. i need the code for it. thanks

  • How can I sync my iPhone 4 with a new Laptop

    Hi Everyone, I have a new Windows laptop and an iPhone 4 (iOS 7.04) and I would like to back it up to my new laptop. The iPhone 4 was sync'd to an older Windows laptop that isn't working anymore, so I can't transfer anything from the old laptop to th

  • How to remove thousands of photos from ipad

    Hi all, When I was at vacation I imported about 7560 photos from my digital camera into the new iPad. At home I imported all the photos from the ipad to Aperure and clicked "delete all the photos from the iPad". Aperture really removed some photos (a

  • How to set block to Outbound delivery?

    Hello Dear Experts, We are creating sales order and creating outbound delivery for that order. This delivery will be distributed (via automatically generated iDoc type DELVRY03) to NONSAP(warehouse management). The problem is that the "Distribution s

  • Can't create subscription

    Dear colleagues, hi Could you please help us with one case. We faced with a problem working on Sybase  RS 12.6 and ASE 12.5.4 I have WarmStabdBy replication but now I want create replication definition and subscription on one table. In all manual I r