Why I cannot edit and updat tree node in this program??

Dear Friends:
I have following code, it can be run ok,
I set it editable, I hope to edit at run time, but looks like I cannot edit,
what is wrong??
Can you help??
Thanks
package treeSelectionListener;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.*;
public class SelectableTreeTest extends JFrame
     public SelectableTreeTest(){
          JPanel jp = new JPanel();
          JPanel jp2 = new JPanel();
        MyTree myTree= new MyTree();
        MyTree myTree2= new MyTree();
        JTabbedPane tabbedPane = new JTabbedPane();
        tabbedPane.setPreferredSize(new Dimension(600,400));
        jp.setPreferredSize(new Dimension(600,400));
        jp2.setPreferredSize(new Dimension(600,400));
        myTree.setPreferredSize(new Dimension(600,400));
        myTree2.setPreferredSize(new Dimension(600,400));
        JScrollPane   jsp = new JScrollPane();
        jsp.setPreferredSize(new Dimension(600,400));
          add(jsp, BorderLayout.CENTER);
          jsp.setViewportView(tabbedPane);
          jp.add(myTree);
          jp2.add(myTree2);
          tabbedPane.addTab("1st Tree", jp);
          tabbedPane.addTab("2nd Tree", jp2);
    public static void main(String[] args) {
        JFrame frame = new SelectableTreeTest();
        WindowUtilities.setNativeLookAndFeel();
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
        frame.pack();
        frame.setVisible(true);
  public class MyTree extends JTree implements TreeSelectionListener {
  private JTree tree;
  private JTextField currentSelectionField;
  public MyTree() {
    Container content = getContentPane();
    DefaultMutableTreeNode root =
      new DefaultMutableTreeNode("Root");
    DefaultMutableTreeNode child;
    DefaultMutableTreeNode grandChild;
    for(int childIndex=1; childIndex<4; childIndex++) {
      child = new DefaultMutableTreeNode("Child " + childIndex);
      root.add(child);
      for(int grandChildIndex=1; grandChildIndex<4; grandChildIndex++) {
        grandChild =
          new DefaultMutableTreeNode("Grandchild " + childIndex +
                                     "." + grandChildIndex);
        child.add(grandChild);
    tree = new JTree(root);
    tree.setEditable(true);
    tree.addTreeSelectionListener(this);
    content.add(new JScrollPane(tree), BorderLayout.CENTER);
    currentSelectionField = new JTextField("Current Selection: NONE");
    content.add(currentSelectionField, BorderLayout.SOUTH);
    setSize(250, 275);
    setVisible(true);
  public void valueChanged(TreeSelectionEvent event) {
    currentSelectionField.setText
      ("Current Selection: " +
       tree.getLastSelectedPathComponent().toString());
}

change this
tree = new JTree(root);
tree.setEditable(true);
tree.addTreeSelectionListener(this);to this
setEditable(true);
addTreeSelectionListener(this);and this
currentSelectionField.setText
  ("Current Selection: " +
   tree.getLastSelectedPathComponent().toString());to this
currentSelectionField.setText
  ("Current Selection: " +
  getLastSelectedPathComponent().toString());and remove this
private JTree tree;

Similar Messages

  • Edit and update multiple records in JSP buisness components

    Hi everybody,
    I'm building BC4J components using entities and views and JSP buisness components.
    how can I edit and update multiple records
    at a time in the jsp file
    Note using the databean
    "oracle.jbo.html.databeans.EditCurrentRecord"
    one can view one record at a time
    thank you

    do you have a sample code? thanks
    Hi
    There are several options. One of them could be
    1) use <input name=rc[j] value="..."> instead of
    display a raw text
    2) parse parameters in doPost method of your servlet
    to update appropriate values.
    3) Make a empty row enable inserts
    Regards
    Jan

  • TS3694 IPHONE 3G CANNOT RESTORE AND UPDATE ERROR CODE 1015

    IPHONE 3G CANNOT RESTORE AND UPDATE ERROR CODE 1015

    Unauthorized modification of iOS
    http://support.apple.com/kb/HT3743
    ERROR 1015...
    This Error Code is indicative of the Device being jailbroken / Hacked...
    Sorry... But...
    The discussion of Jailbroken Devices is against the Terms of Use of this Forum.
    You will need to look elsewhere.

  • Why I cannot send and receive emails when I am in other countries other my original

    Why I cannot send and receive emails when I am in other countries other my original country ?

    iOS: Unable to send or receive email
    http://support.apple.com/kb/TS3899
    Can’t Send Emails on iPad – Troubleshooting Steps
    http://ipadhelp.com/ipad-help/ipad-cant-send-emails-troubleshooting-steps/
    iPad Mail
    http://www.apple.com/support/ipad/mail/
    Try this: Delete the account in Mail and then set it up again.
     Cheers, Tom

  • Getting this:You cannot install Security Update 2011-002 on this volume. This volume does not meet the requirements for this update?

    I am getting this message: You cannot install Security Update 2011-002 on this volume. This volume does not meet the requirements for this update?
    is there a way to install this update?

    Hello
    More information would be useful, for example which Mac OS are you running.
    On the left menu item  About this Mac provides useful information.
    Also did you use Software Update to determine the update?
    Using Software Update can ensure you download and install the correct package for your particular Mac and OS version.

  • HT201304 why I cannot conect to the iTunes store with this iPad?

    why I cannot conect to the iTunes store with this iPad?
    when  I want to download something, always show me " cannot connect to the intues store ? What I can do now ?

    Usually it's because you are not making internet connection via wifi.
    Look at iOS Troubleshooting Wi-Fi networks and connections  http://support.apple.com/kb/TS1398
    iPad: Issues connecting to Wi-Fi networks  http://support.apple.com/kb/ts3304
    iOS: Recommended settings for Wi-Fi routers and access points  http://support.apple.com/kb/HT4199
    Additional things to try.
    Try this first. Turn Off your iPad. Then turn Off (disconnect power cord) the wireless router & then back On. Now boot your iPad. Hopefully it will see the WiFi.
    Change the channel on your wireless router. Instructions at http://macintoshhowto.com/advanced/how-to-get-a-good-range-on-your-wireless-netw ork.html
    How to Quickly Fix iPad 3 Wi-Fi Reception Problems
    http://osxdaily.com/2012/03/21/fix-new-ipad-3-wi-fi-reception-problems/
    If none of the above suggestions work, look at this link.
    iPad Wi-Fi Problems: Comprehensive List of Fixes
    http://appletoolbox.com/2010/04/ipad-wi-fi-problems-comprehensive-list-of-fixes/
    Fix iPad Wifi Connection and Signal Issues  http://www.youtube.com/watch?v=uwWtIG5jUxE
     Cheers, Tom

  • Cannot reinstate catalog after returning PC (Windows 7) to factory settings (because of worm infection). Catalog was backed up on external drive but not using PSE backup facility. Cannot find and *.tly file. Is this hopeless?

    Cannot reinstate catalog after returning PC (Windows 7) to factory settings (because of worm infection). Catalog was backed up on external drive but not using PSE backup facility. Cannot find and *.tly file. Is this hopeless?

    If you made backups of all of your photos and your catalog file using some third-party method (i.e. not using the PSE catalog backup command), then you should be able to restore everything.
    Step 1. Put the photos in the EXACT SAME LOCATION as before. For example, if they were in subfolders of C:\Users\<username>\Documents, then they must go into the exact same subfolders of C:\Users\<username>\Documents.
    Step 2. Move the catalog file to wherever you want it to be, and then double-click on it.

  • Update tree node icon, better way?

    Hi,.
    I have my own custom renderer for my JTree....such as
    public class MyTreeNodeRenderer extends JLabel implements TreeCellRenderer {
    public Component getTreeCellRendererComponent(
            JTree treeVal,
            Object valueVal,
            boolean selectedVal,
            boolean expandedVal,
            boolean leafVal,
            int rowVal,
            boolean hasFocusVal) {
            MyTreeNode node = (MyTreeNode) valueVal;
              // get the latest type for this node
            node.type = getType(node);
            if (node.type == 1) {
                    setIcon(TYPE1_ICON);
             else {
                    setIcon(TYPE_BASIC_ICON);
                   return this;
    }...intially the tree nodes have their icons, as they should...later on their "type" is updated...so instead of being 1..its now something else...so the icon should change.....but it doesnt occur fast enough...so i added this to my renderer
    public void doRepaint() {
            repaint();
            myTree.repaint();
        }basically anytime i needed to update the icon in the tree i called the doRepaint when i want the new icon to appear in the tree..that helped somewhat..but it is still kinda slow....any ideas how to do this?

    valueForPathChanged() serves different purposes as you can see from its description. You need to call treeModel.nodeChanged(node) after your node changed its "type". If you don't want to hold or don't have treeModel reference you could use tree classes from .useful library and be able to call nodeChanged() directly from a node that has been changed.
    Denis Krukovsky
    http://dotuseful.sourceforge.net/

  • How to edit and update table control into database?

    I am doing table control. Here are my codes:
    *& Report  ZHERA_TABLE2
    REPORT  ZHERA_TABLE2.
    ***&SPWIZARD: DATA DECLARATION FOR TABLECONTROL 'ZTABLE_CONTROL'
    *&SPWIZARD: DEFINITION OF DDIC-TABLE
    TABLES:   ZHERA.
    *&SPWIZARD: TYPE FOR THE DATA OF TABLECONTROL 'ZTABLE_CONTROL'
    TYPES: BEGIN OF T_ZTABLE_CONTROL,
             NAME LIKE ZHERA-NAME,
             AGE LIKE ZHERA-AGE,
           END OF T_ZTABLE_CONTROL.
    *&SPWIZARD: INTERNAL TABLE FOR TABLECONTROL 'ZTABLE_CONTROL'
    DATA:     G_ZTABLE_CONTROL_ITAB   TYPE T_ZTABLE_CONTROL OCCURS 0,
              G_ZTABLE_CONTROL_WA     TYPE T_ZTABLE_CONTROL. "work area
    DATA:     G_ZTABLE_CONTROL_COPIED.           "copy flag
    *&SPWIZARD: DECLARATION OF TABLECONTROL 'ZTABLE_CONTROL' ITSELF
    CONTROLS: ZTABLE_CONTROL TYPE TABLEVIEW USING SCREEN 1000.
    START-OF-SELECTION.
    CALL SCREEN 1000.
    *&SPWIZARD: OUTPUT MODULE FOR TC 'ZTABLE_CONTROL'. DO NOT CHANGE THIS LI
    *&SPWIZARD: COPY DDIC-TABLE TO ITAB
    MODULE ZTABLE_CONTROL_INIT OUTPUT.
      IF G_ZTABLE_CONTROL_COPIED IS INITIAL.
    *&SPWIZARD: COPY DDIC-TABLE 'ZHERA'
    *&SPWIZARD: INTO INTERNAL TABLE 'g_ZTABLE_CONTROL_itab'
        SELECT * FROM ZHERA
           INTO CORRESPONDING FIELDS
           OF TABLE G_ZTABLE_CONTROL_ITAB.
        G_ZTABLE_CONTROL_COPIED = 'X'.
        REFRESH CONTROL 'ZTABLE_CONTROL' FROM SCREEN '1000'.
      ENDIF.
    ENDMODULE.
    *&SPWIZARD: OUTPUT MODULE FOR TC 'ZTABLE_CONTROL'. DO NOT CHANGE THIS LI
    *&SPWIZARD: MOVE ITAB TO DYNPRO
    MODULE ZTABLE_CONTROL_MOVE OUTPUT.
      MOVE-CORRESPONDING G_ZTABLE_CONTROL_WA TO ZHERA.
    ENDMODULE.
    Screen 1000 codes:
    PROCESS BEFORE OUTPUT.
    *&SPWIZARD: PBO FLOW LOGIC FOR TABLECONTROL 'ZTABLE_CONTROL'
      MODULE ZTABLE_CONTROL_INIT.
    *&SPWIZARD: MODULE ZTABLE_CONTROL_CHANGE_TC_ATTR.
    *&SPWIZARD: MODULE ZTABLE_CONTROL_CHANGE_COL_ATTR.
      LOOP AT   G_ZTABLE_CONTROL_ITAB
           INTO G_ZTABLE_CONTROL_WA
           WITH CONTROL ZTABLE_CONTROL
           CURSOR ZTABLE_CONTROL-CURRENT_LINE.
    *&SPWIZARD:   MODULE ZTABLE_CONTROL_CHANGE_FIELD_ATTR
        MODULE ZTABLE_CONTROL_MOVE.
      ENDLOOP.
    MODULE STATUS_1000.
    PROCESS AFTER INPUT.
    *&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'ZTABLE_CONTROL'
      LOOP AT G_ZTABLE_CONTROL_ITAB.
        CHAIN.
          FIELD ZHERA-NAME.
          FIELD ZHERA-AGE.
        ENDCHAIN.
      ENDLOOP.
    *&SPWIZARD: MODULE ZTABLE_CONTROL_CHANGE_TC_ATTR.
    *&SPWIZARD: MODULE ZTABLE_CONTROL_CHANGE_COL_ATTR.
    MODULE USER_COMMAND_1000.
    Please show me where to put my codes to edit(edit directly on table control fields) and update my table control(using the 'save' button)?

    Hi,
    You have to put the following code in the PBO of screen 1000.This code would make the fields editable to make changes in the table control fields directly.
    Here there are 3 transactions.For create and change transactions, the fields will be in editable mode and for display transaction,they will be non editable mode.
    DESCRIBE TABLE tb_line LINES lin.    " tb_line is the name of the internal table for the table control
      tcl_item-lines = lin.                             '' lin hold the number of lines of the internal table
    CASE sy-tcode.
        WHEN 'ZCREATE09' OR 'ZCHANGE09'.
    ***Checking if the table control is empty or not***
          IF lin NE 0.       
            LOOP AT SCREEN.
    ***To make the screen editable****
              screen-input = 1.
            ENDLOOP.
          ELSE.
            LOOP AT SCREEN.
              IF screen-name CS 'TB_LINE'.
    ****To make the screen non-editable if no values are present in the
    ***table control****
                screen-input = 0.
                MODIFY SCREEN.
              ENDIF.
            ENDLOOP.
          ENDIF.
    Once the fields are edited and the save button is pressed,the entered values have to be populated into the Z tables.The code has to written in the PAI of the screen 1000.Here the values from the work area of the internal table are moved into the Z Table. The code will be.
    LOOP AT tb_line.
        ztm09_ekpo-ebeln = ztm09_ekko-ebeln.  "ztm09_ekko and ztm09_ekpo are the names of the Z Tables.
        ztm09_ekpo-ebelp = tb_line-ebelp.   
        ztm09_ekpo-matnr = tb_line-matnr.
        ztm09_ekpo-menge = tb_line-menge.
        ztm09_ekpo-meins = tb_line-meins.
        ztm09_ekpo-netpr = tb_line-netpr.
        ztm09_ekpo-waers = tb_line-waers.
    *****Update the entries into item table*****
        MODIFY ztm09_ekpo.
      ENDLOOP.
    Reward if helpfull
    Thanks,
    Kashyap

  • Why is the Edit and + feature missing in Contacts?

    Since updating my iPhone 4 to iOS 5 the "Edit" and "+" feature is missing from Contacts.

    Already tried that and it did not fix/repair the issue.  From other similar posts I gather it might be that the Contacts on my iPhone are ONLY on my iPhone.  I do not sync them with my home computer (no longer an option especially in that iCloud is not supporting Windows XP) and do not sync with my work computer because I prefer not to have 600 contacts on my iPhone.  The problem only appeared after updating to iOS 5, so I am surmising it has something to do with that and the features of or expectations that everyone will migrate to iClould.  Sort of BS if that is the case because it appears I am being given no choice but to upgrade my home computer to Windows 7 (or a Mac) and put everything on the cloud.

  • Editing and updating a row in Datagrid

    Hi All,
    I am getting the list of records from database and displaying those records in Datagrid with the help of dataprovider.
    i want to edit any record and have to update.
    How can i do this. Can any one help me.
    thanks
    Raghu.

    You'll need to implement a change event handler that calls an HTTPService, WebService, or RemoteObject. See these links for more info:
    http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_2.html
    http://livedocs.adobe.com/flex/3/html/help.html?content=dpcontrols_7.html
    http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/
    If this post answers your question of helps, please mark it as such.

  • How to persist parent  and child tree node data through JSF and Hibernate

    Dear dudes,
    I'm a novice to JSF and Hibernate
    Actually i want to create a tree structure where for each child node, i should have the parent node reference in my form and then when i save, i need to save the corresponding child node data in the database.
    node-1
      node 1-1
         node 1-11a
      node 1-2
    node-2
       node 2-1
       node2-2Whenever i click node 1-1 the corresponding parent node ( node-1) reference should appear in my form and when i save this data this data should be saved under parent node and the tree should be re-rendered.
    How this can be accomplished and if there are any URL's please refer.

    Everybody need not face the same problem you faced. And moreover, everyone out here have their own issues to solve. If people are helping out here, its cause of their passion. Please try to be polite.
    First of all, what is that you have tried on the issue? Could you please share your work so that we can try to fill the gaps?

  • Anybody know why I cannot edit the contents of my captions?

    Okay, I can delete text captions, smart shapes with text content, or failure captions, but for the first project I have started in Captivate 8 I cannot edit their contents.
    I just converted a project from Captivate 7 into C8, and added newly recorded slides to it.  Those captions are editable.  BUT the ones from the freshly started project are not.  When I try to click on the text caption at the top of the timeline, or any other caption in the window, my cursor flips from the pointing finger, to the fist, as long as I hold the mouse button down.  Then it flips back to the pointing finger instead of giving me the I-beam cursor for editing.
    This is a software simulation and the captions were added automatically during the recording phase and must be edited.
    My project is not responsive.  Here is a snip of the editing window for this project.
    Thanks for any help you can offer.
    Michele

    No, Lieve, that hadn't occurred to me.  I tried it just now and I do get an I-beam, but when I try to select the text all I get is a dashed box that I seem to be drawing with the I-beam cursor.  It draws over the caption and  will go as large as I let it before letting go of my mouse. It doesn't allow me to edit the text.  It is like the text is locked somehow, but you can see from my image above that it isn't.
    I have also saved this project by another name and the new one does the same thing.  Am I going to have to go through this course, delete ALL of the captions and recreate them manually? 

  • Single Edition and update

    How many update i can upload with single edition?

    One limitation not mentioned here, however, is that the serial number associated with a Single Edition license expires after a year. The license only allows you to build (and update) your application for a one-year period. After a year, you need to either subscribe to Creative Cloud (which will entitle you to build an unlimited number of Single Edition applications as you're a subscriber) or purchase a new serial number through the Adobe Store. Hint: The cost of a Single Edition serial number is $395 whereas the cost of a subscription to Creative Cloud is $49.99/month (with a 40% discount if you're upgrading from Creative Suite).

  • How can I edit the selected tree node immediately?

    I have completed a popup menu ,which appeares when I have a mouse rightclicked event
    over the selected tree node.when I selected the popup menu item,i can edit the tree node ,but
    I feel that the tree celleditor appear slowly ,what should i do? the following is my code:
    menuItemRenameNode.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    renameNode_ActionPerformed(ae);
    void renameNode_ActionPerformed(ActionEvent ae){
    setEditable(true);
    this.getCellEditor().addCellEditorListener(new CellEditorListener(){
    public void editingCanceled(ChangeEvent e){
    CellEditor cellEditor =(CellEditor)e.getSource();
    System.out.println("editing canceled:"+cellEditor.getCellEditorValue().toString());
    protected boolean canEditImmediately(EventObject e){
    return true;
    public void editingStopped(ChangeEvent e){
    CellEditor cellEditor =(CellEditor)e.getSource();
    System.out.println("editing stopped:"+cellEditor.getCellEditorValue().toString());

    Please check the suggestions in the thread: https://forums.adobe.com/thread/692020?tstart=0
    Regards,
    | T. Ravi Kumar

Maybe you are looking for

  • Unable to Delete Files From Bridge CS4

    I am trying to delete file from bridge and all the sudden I am getting the message that I dont have permisson to delete file. I have done several troubleshooting methods and nothing works. Deleted prefs, cache, checked file permisions, repaired HD pe

  • Multibyte character support in Jdbc Driver

    Hi, I want to use multibyte characters in my Application and to store it in my database. If my database provider does not support a Multibyte data type, Can my Jdbc Driver provide support for the same ? For a column of type ISO88591 which is of singl

  • ITunes launches unexpectedly

    After I quit out of iTunes, it will launch unexpectedly after about 30-60 seconds. I could be working in another program and iTunes will pop up on the screen. This is extremely annoying. Help! I have iTunes 7.3.1 (3) loaded.

  • Select query dump

    Hi all, tables: ikpf,iseg. TYPES: BEGIN OF i_ikpf,        werks TYPE ikpf-werks,    "Plant        lgort TYPE ikpf-lgort,    "Storage location        iblnr TYPE ikpf-iblnr,    "Physical Inventory Document        gjahr TYPE ikpf-gjahr,    "Fiscal Year

  • Planned order based capacity planning

    Dear Guru's, Is it possible to view & analyse work load on work centers for planned orders in R/3? Please let us know the settings to be done if needed. Regards, SAP CONS