How can I add a node with with a user-chosen name  to JTree in one action

The functionality that I would like to implement is to add a new node to a tree (JTree with DefaultTreeModel), that during the adding process of the the new node the user will type the node name.
I am using the following documentation as a reference: http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html#select
but in this example (as well as all the other examples that I found on net) the user can add first a new node with a constant name (like "NewNode").
and then in a seperated action the user can edit this node. I'd like to perfrom it in one action.
one solution that could be implemented is on the end of the adding node invoking beginning of editing action that will be triggered in code instead of forcing the user to click with the mouse on the selected node. The question is how can I do it? how can I trigger an edit action on a selected node in a JTree?
Edited by: Rotshield on Aug 23, 2008 2:21 AM
Edited by: Rotshield on Aug 23, 2008 2:24 AM
Edited by: Rotshield on Aug 23, 2008 2:29 AM
Edited by: Rotshield on Aug 23, 2008 2:29 AM

Ah, well.
You can lead a horse to the water but you can't make it drink.
Just to provide some background, I'm not a developer, just a hobby programmer and first took up Java less than 14 months ago. I didn't know the answer to your problem, but on reading the API it was fairly clear which method I'd have to make use of. In less than half an hour of coding, I had a JFrame with a JTree and a JButton to add a node, which was immediately in editing condition.
Try to find another profession, Rotshield. Or at least don't disgrace the community by calling yourself a Java developer (for 4 years lol) until (if ever) you learn how to read and apply an API.
db

Similar Messages

  • How can I add header on printing with Numbers

    How can I add header on printing with Numbers? The previous version use to have it and I cannot find it in the new one ...

    Hi Tanya,
    Glad to hear that you found how to edit page headers and footers in Numbers 3.2. I agree that Help in Numbers 3 is woeful. No searchable PDF to download and use offline. All is online (one page at a time) and we need to know the terms we are looking for before we look.
    The first HelpDesk:
    http://www.youtube.com/watch?v=pQHX-SjgQvQ
    For printing to paper where layout is important, I use Numbers '09 (Numbers 2.3) with its Print View. But it is orphanware. As the name suggests, there has not been a major overhaul since 2009. With that in mind, it is a useful version to hang onto while we hope and wait (and provide feedback to Apple) for something in future versions of Numbers 3.x to provide better layout capability.
    Indeed, each new update of Numbers 3.x has restored more of the old features while adding new features that are enhancements over Numbers '09. Many of the Numbers 3 enhancements reflect long-awaited wishes through this forum, and were passed on by Numbers Feedback to Apple. So it seems that Apple does take heed of feedback.
    In the meantime, I enjoy the charm of Numbers '09 whilst exploring the new features of Numbers 3.
    What has been GAINED in Numbers 3 is here:
    https://discussions.apple.com/thread/5473882?start=75&tstart=0
    (Very long thread because it started with Numbers 3.0, and enhancements have continued through Numbers 3.2).
    Hints on workarounds in Numbers 3 is here:
    https://discussions.apple.com/message/23622372#23622372
    Some workarounds are no longer needed, but what amazes me is how many Numbers '09 features (the so-called "lost" features) were not lost; the settings have simply been moved. Moreover, many features such as margin settings carry over with a Numbers '09 document or template into Numbers 3.
    Hints for layout on screen before printing to paper:
    Try Alignment Guides and Rulers as suggested here:
    Print View workarounds
    Use a layout guide:
    Layout Guide for Numbers
    Regards,
    Ian.

  • How can I add roles or features with using WMI?

    Can I add features in Windows server 2008/2012 with using WMI? I found only how to see installed features, but can`t found anything in my question. Can anybody help?

    Hi,
    I agree with Ed’s suggestion. Just in addition, you can install roles, role services, or features via
    Install-WindowsFeature PowerShell cmdlets. Please refer to following TechNet article and check if can help you.
    Install-WindowsFeature
    If any update, please feel free to let us know.
    Hope this helps.
    Best regards,
    Justin Gu

  • How can I add a Mail folder with the "Inbox, Sent, and Trash" folders?  I have Windows 8.1

    After I installed the 7.0.6 update, my iPhone crashed & had to do a restart.  I saved my Contacts.  I've been syncing my iPhone to store data on my PC instead of iCloud.  I'm assuming all of my pictures etc. are in the iPod Photo Cache, which I cannot open since they are THMB files.  How can I view all of my "lost" data without having to pay for the "Converter" program, which according to many of the people in my boat, say doesn't work & is a rip off?  I'm also trying to put an "Archive" folder back in my Mail folder.  I've tried to follow instructions but my iPhone 7.1 does not have the same options.  All of this is so frustrating.....load an upgrade & screws a lot of stuff up.  Just like "Trust this computer?" on 7.0.6 update.  Anyway, I hope someone can help with these minor problems.
    Thank you.
    Leo Nard

    Not in Mail. If you referring to not having to use the menu, you can click the + sign at the bottom to create new mailboxes. But you still have to fill in the window with location and name. You can right click to create a new mailbox on an existing one, but not in the main account itself and you still have to fill in the info. It would create a sub folder.
    You can also try it at the gmail website. There might be shortcuts there.

  • How can i add a new signature with PKCS1?

    The default sign method of Acrobat is PKCS7,how to change to PKCS1?
    Thanks!

    Hi,
    There are two different tacks you could take here. One way is to set a Seed Value that works on a per signature field basis and the other is to make a change to the registry that works on a general basis. Of course, a change to the registry it's on a per computer basis where as Seed Value, because it's on a per document basis will travel from computer to computer.
    If you want to set the Seed Value it's done via JavaScript. Go to http://livedocs.adobe.com/acrobat_sdk/9/Acrobat9_HTMLHelp/wwhelp/wwhimpl/js/html/wwhelp.ht m?href=JS_API_AcroJS.88.1.html#1515776&accessible=true and click the Search button and look for "Seed Value". When it returns, click on "signatrueSetSeedValue" and then scroll down to Example 2 to see how to set the subFilter. You're going to want to use the value adbe.x509.rsa_sha1 as opposed to what is shown in the example.
    If you would rather make the change global to the computer then you need to modify the registry (Windows) or plist (Mac). I'll give you an example for Windows, but if you need help with the Mac let me know. Run regedit and then go to HKEY_CURRENT_USER\Software\Adobe\Adobe Acrobat\9.0\Security\cPubSec with the following caveats. First, if you are using Reader, as opposed to Acrobat, change \Adobe Acrobat\ to \Acrobat Reader\. The other thing is, if you are using an earlier version of Acrobat change "9.0" to the major version number you are currently running. Even if you were using version 8.1 you would still look for 8.0.
    Now that you've navigated to the correct location add the Binary Value "aSignFormat" (without the quotes). Next, edit the value and click into the right side of the dialog and add the same plain text string noted above for use with Seed Value. Please see the attached screen shot (click on the link below to open the picture and then click on the black X to close it). An important thing to note here is the string needs to be NULL terminated. After you've type the plain text string into the right side of the dialog, click into the end on the hex string at the left side and type a zero. You'll note that it adds what appears to be a dot at the end of the plain text string on the right, but it's not really a dot.
    I hope this helps,
    Steve

  • How can I add a row into a JTable with JButton

    Hi all. I have the following code:
    package gui;
    import db.*;
    import javax.swing.table.AbstractTableModel;
    import java.util.ArrayList;
    public class FoundersTable extends AbstractTableModel{
        private static final int COLUMNS = 8;
        private String columnNames[] = {"��� ����", "���", "�������", "�������", "���������", "��������",
                "����� �� ����������", "������ �� ����, �����"};
        private ArrayList data;
        public FoundersTable(){
            data = new ArrayList();
        public int getRowCount() {
            return data.size();
        public int getColumnCount() {
            return columnNames.length;
        public String getColumnName(int colIndex) {
            return columnNames[colIndex];
        public Object getValueAt(int rowIndex, int columnIndex) {
            return ((ArrayList)data.get(rowIndex)).get(columnIndex);
        public void setValueAt(Object value, int rowIndex, int columnIndex) {
            ((ArrayList)data.get(rowIndex)).set(columnIndex, value);
            fireTableCellUpdated(rowIndex, columnIndex);
        public void addRow(ArrayList neueZeile) {
            data.add(neueZeile);
            int index = data.size() - 1;
            fireTableRowsInserted(index, index);
        public void removeRow(int index) {
            data.remove(index);
            fireTableRowsDeleted(index, index);
        public void removeAllRows() {
            data.clear();
            fireTableRowsDeleted(0, 0);
        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return true;
    }Now in my MainJFrame class I have one button for additing and one button for removing a selected row. How can I add/remove rows with this two buttons.
    Thanks

    No my question is how can I add and remove rows WITH buttons My point was the code is the same. You use the addRow(...) method. Why did you write an addRow(...) method if you aren't going to use it?
    I don't understand your problem. Do you not know how to write an ActionListener?

  • How can i add formula to waveform data type?

    I want to interpolate my acquired data in terms of voltage to temperature. For this i need to use polynomial equation, but i am not able to directly attach formula node to the waveform data type. I want to know how can i add formula node to waveform data, and then also have it real time.

    One additional thought that may be helpful. Once you get the Y component of the waveform graph you are going to attempt to wire this into a formula node. You can do one of two things with that array. Put a for loop around the formula node and index the array into and out of the for loop. This allows you to do scalar math on the data. It is also possible to index and array in a formula node. The following KnoledgeBase demonstrates how to do this: http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/9d72b6069346942386256a0d00604ed4?OpenDocument

  • Using the value "Image/*" for the accept attribute of the HTML input Element, how can I add .pdf to the array of preconfigured file types (.jpe, .jpg, .jpeg, .?

    On a form, using the value "image/*" for the accept attribute of the HTML input Element, how can I add .pdf to the array of pre-configured file types (.jpe, .jpg, .jpeg, .gif, .png, .bmp, .ico, .svg, .svgz, .tif, .tiff, .ai, .drw, .pct, .psp, .xcf, .psd, .raw)?
    Say I wanted to add .gif, .jfif or .ico. I find this array limited, how can I add types to image?
    <input type="file" name="file" accept="image/*" id="file" />
    mimeTypes.rdf does not seem to allow this.

    ''mimeTypes.rdf'' has nothing to do with web development. It's a file that stores your file handling preferences (e.g. if you want ZIP files automatically saved or opened).
    You can't change the file types of the pre-defined content specifiers (audio/*, video/*, image/*), but you can specify additional MIME types. To add PDF to your above example,
    <pre><nowiki><input type="file" name="file" accept="image/*,application/pdf" id="file" /></nowiki></pre>
    For details, see
    * [https://developer.mozilla.org/En/HTML/Element/Input developer.mozilla.org/En/HTML/Element/Input]

  • How can I add a client wireless usig Airport Utility 6.0?

    In menu airport of firmware 6.0 there is not window "Add a wireless client". I'm using Mac Os lion with Airport Utility6.0, how can I add a client wireless with this firmware)?

    If you have a dual band AirPort Extreme, you can add another to "extend" both bands of your network to provide more  wireless coverage.
    The "best" way to do this is to connect the "remote" access point back to your main AirPort Extreme using an Ethernet connection. This preserves bandwidth on the network better than any other method...and...you can locate the "remote" Extreme exactly in the area where more coverage is needed. Instructions for thhis are here:
    http://support.apple.com/kb/HT4260
    You might be able to connect using wireless only, but this is always "Iffy".
    In general, the Extreme would need to be located approximately half the distance from your main router to the general area that needs more coverage. But, walls, ceilings and other obstructions usually come into play, requiring some experimentation. Instructions are here:
    http://support.apple.com/kb/HT4259
    If you elect to try wireless, you really won't know if things will work until you try. Recommend that you have a "Plan B" if wireless does not work for your purpose.

  • How do you add an additional serial number to TestStand logfile name?

    I have two boards that are tested as a pair and I would like to have the log name show both serial numbers for tracking purposes. The logfile name is currently set up to show the serial number of the mainboard.  I put the second serial number into a StationGlobal after it is scanned it in. How can I add the second serial number to the logfile name?
    Thanks
    Tracey

    Hi vocollect,
    I have found a Community Example that demonstrates how to modify the report name in Report Options. The pictures may not show exactly what you see If you are using TestStand 2012, but the steps are essentially the same. I hope this helps!
    How to Add User Information to a Report Name: https://decibel.ni.com/content/docs/DOC-21744
    Regards,
    Jason D
    Applications Engineer
    National Instruments

  • IF_IXML : How can i add encoding with value UTF-8 to the document object??

    Hi
    i want to create a xml file with the following content:
    <?xml version="1.0" encoding="UTF-8"?>
    <OpenSearchDescription xmlns="http://...."> 
    </OpenSearchDescription>
    i did this with the if_ixml interface and rendered the content in a file 'D:\usr\sap\IFD\DVEBMGS01\log\TEST_out.xml
    <?xml version="1.0"?>
    <OpenSearchDescription xmlns="http://...."> 
    </OpenSearchDescription>
    BUT the document attribut(?) encoding="UTF-8"?> is missing!
    How can i add encoding with value UTF-8 to the document object?? it should look like:
    <?xml version="1.0" encoding="UTF-8"?>
    *here is my coding.
    TYPE-POOLS: ixml.
    CLASS cl_ixml DEFINITION LOAD.
    DATA: lo_ixml           TYPE REF TO if_ixml,
          lo_streamfactory  TYPE REF TO if_ixml_stream_factory,
          lo_document       TYPE REF TO if_ixml_document,
          lo_parent         TYPE REF TO if_ixml_element,
          lo_ostream        TYPE REF TO if_ixml_ostream,
          lo_renderer       TYPE REF TO if_ixml_renderer,
         lv_rc           TYPE i.
    lo_ixml = cl_ixml=>create( ).
    lo_streamfactory = lo_ixml->create_stream_factory( ).
    lo_document = lo_ixml->create_document( ).
    lo_parent = lo_document->create_simple_element( name   = 'OpenSearchDescription'  "root node
                                                    parent = lo_document ).
    lo_parent->set_attribute_ns( name   =  'xmlns'
                                 value  = 'http://....' ).
    *rausrendern in file
    lo_ostream = lo_streamfactory->create_ostream_uri( system_id = 'D:\usr\sap\IFD\DVEBMGS01\log\TEST_out.xml' ).
    lo_renderer = lo_ixml->create_renderer( ostream  = lo_ostream
                                            document = lo_document ).
    lv_rc = lo_renderer->render( ).
    Thanks for help
    Britta

    Use the following code:
    set an document encoding
      l_encoding = l_ixml->create_encoding( character_set = 'UTF-8'
                                            byte_order = if_ixml_encoding=>co_none ).
      l_success  = l_ostream->set_encoding( encoding = l_encoding ).
    create a xml renderer
      l_renderer = l_ixml->create_renderer( document = l_doc ostream  = l_ostream ).

  • How can I add more than one same spry menu (eg. collapsible menu)  with in different styles (font size, color, background, etc) on current page?

    How can I add more than one same spry menu (eg. collapsible menu)  with in different styles (font size, color, background, etc) on current page?

    Hi Nancy,
    This screenshot was only for imagination. A part of the code (not all) is below.  In the code there are some background images but they are not seem in live mode.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="css/my_site.css" rel="stylesheet" type="text/css" />
    <link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css"/>
    <link href="SpryAssets/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" />
    <script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
    <script src="SpryAssets/SpryCollapsiblePanel.js" type="text/javascript"></script>
    <style>
    #CollapsiblePanel1 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-color: #003366;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel1 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        line-height: 52px;
    #CollapsiblePanel1 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        line-height: 52px;
    #CollapsiblePanel2 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/international.jpg);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel2 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel2 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel2 .CollapsiblePanelContent {
        background-color: blue;
    #CollapsiblePanel3 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel3 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel3 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel4 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel4 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel4 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel5 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel5 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel5 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    </style>

  • How can I add an email account in apple mac which ends with .consulting

    We changed our email account and the domain name is .consulting. How can I add this account to my Mac mail?

    If you are trying to activate an iPad or iPhone and it is asking for a previous Apple ID and password, you have encountered the Activation Lock. This is a security feature that prevents thieves from setting up and using a stolen or lost iPad or iPhone. You have no alternative. You must use the previous Apple ID and password to unlock the device. If you do not know the password you might be able to recover it at this link:
    https://iforgot.apple.com/password/verify/appleid
    This normally will require that info is sent to the primary email address associated with the Apple ID. If you have an alternate email address assigned to that Apple ID you might get the password via the alternate email address.

  • How can i add a new user and change user'password with javamail?

    how can i add a new user and change user'password from a mailserver with javamail?
    email:[email protected]

    Well user creation and updation is a system property..U need to go through that part...as it depends on the system you are hosting pout your application...
    if it is linux...u have to use some shell programming\
    bye for now let me know if this guides you or if you need some more stuff.
    bye

  • Had 3G, moved to 3GS.  Backed up 3G and restored 3GS from backup with no problem.  When I want to add songs, I get itunes message that the new iphone is synced to another computer and now wants to erase everything.  How can I add music?

    Had 3G, moved to 3GS.  Backed up 3G and restored 3GS from backup with no problem on a Dell computer.  But now when I want to add songs, I get itunes message of death that the new iphone is synced to another computer and now wants to erase everything.  How can I add music without erasing everything on my new iphone?

    Yes, I was aware of this but the phrase "Any items imported from audio CDs or acquired from other sources will not copy from your device to the iTunes library." is what worries me.  Will this eliminate my Notes, Calendar Events, etc or will it apply mostly just to the music?

Maybe you are looking for

  • Lightroom encountered an error when reading from its preview cache. helping a friend..

    Im not a lightroom user. even though I have some version 4. I use acdsee pro 6. but my friend has the 5.6 CC version but has a language issue so im trying to help me. basically will guide him over the phone. he was editing a wedding, the computer cra

  • Error handling in bpm

    Hi Experts ,        Can any one please explain the eror handling in BPM. Thanks in advance Naveen

  • WS2008 Active Directory to WS2008 R2

    Hello everyone, I have a little issue from my 2 servers. One is WS2008 (Domain Controller, Printer Server and IIS server) and the other one is WS2008 R2 (File Server). What I do it is I start dcpromo.exe, then expand forest to my domain. But that giv

  • IPhoto library appears corrupted - help

    Within the last week I have upgraded to OS 10.6.3 and iPhoto 8.1.2 When I click on the iPhoto icon in the dock, all of the event icons are intact, but when I click on an individual photo in any event I see a dark screen with an exclamation mark. The

  • Best support option for failing Bluetooth?

    In the past few weeks or so, my Macbook has been losing bluetooth connectivity intermittently. I was hoping that somehow the 10.4.8 update would help, but if anything it's only gotten worse. Now it doesn't just happen when the laptop is hot, but also