Triggering a CellEditor at will in a JTree

Hi,
I have following problem:
My application contains a JTree view of Directories containig audio signal references. After starting the application for the first time(one default directory (node) is always created when app is first started ) and after creating a new directory I want the node text to be directly editable. Is to say I want the cell editor to be triggered just like after pressing default key F2 or clicking once on to the node through the application itself. If possible the text (box) content should be highlighted from the beginning so that all the user has to do is enter his new directory name. This procedure is similar to creating a new directory using the windows file explorer. I understand one can acces routines of the trees CellRenderer but havent found a means to solve my problem yet.
Any ideas anyone? Any help welcome.
Greets,
the lawoguy

Hi joop
Did you try:
JTree tree;
TreePath path;
tree.startEditingAtPath(path);
Good Idea! Unfortunately only the editing is started that is the text box appears.
Neither is a cursor set or the text highlighted.
Is there any mechanism to achieve this from here?
Greets,
the lawoguy

Similar Messages

  • Problem with JTree

    Hi All,
    Can anyone please help me in writing a method which will take a JTree/TreeNode/MutableTreeNode and a string as parameters, and then search the JTree/TreeNode/MutableTreeNode for that particular string (which will be the name of a node/leaf in the tree), and then expand the JTree to show the node/leaf?
    Thanx a lot in advance,
    Best Regards,
    Debopam.

    Here's something:import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    public class Test extends JFrame {
        private TreePanel treePanel;
        public Test () {
            getContentPane ().setLayout (new BorderLayout ());
            getContentPane ().add (treePanel = new TreePanel ());
            getContentPane ().add (new SearchPanel (), BorderLayout.SOUTH);
            pack ();
            setDefaultCloseOperation (EXIT_ON_CLOSE);
            setLocationRelativeTo (null);
            setTitle ("Test");
            setVisible (true);
        public Dimension getPreferredSize () {
            return new Dimension (600, 600);
        private class TreePanel extends JPanel {
            private DefaultTreeModel model;
            private JTree tree;
            public TreePanel () {
                model = new DefaultTreeModel (createRoot ());
                tree = new JTree (model);
                tree.setRootVisible (false);
                tree.setShowsRootHandles (true);
                setLayout (new BorderLayout ());
                add (new JScrollPane (tree));
            private TreeNode createRoot () {
                DefaultMutableTreeNode root = new DefaultMutableTreeNode ("");
                add (root, 1, 3);
                return root;
            private void add (DefaultMutableTreeNode node, int i, int n) {
                for (int l = 0; l < 26; l ++) {
                    DefaultMutableTreeNode child = new DefaultMutableTreeNode (((String) node.getUserObject ()) + (char) ('a' + l));
                    if (i < n) {
                        add (child, i + 1, n);
                    node.add (child);
            public void searchAndExpand (String text) {
                TreeNode[] path = search ((DefaultMutableTreeNode) model.getRoot (), text);
                if (path != null) {
                    TreePath treePath = new TreePath (path);
                    tree.scrollPathToVisible (treePath);
                    tree.setSelectionPath (treePath);
            private TreeNode[] search (DefaultMutableTreeNode node, Object object) {
                TreeNode[] path = null;
                if (node.getUserObject ().equals (object)) {
                    path = model.getPathToRoot (node);
                } else {
                    int i = 0;
                    int n = model.getChildCount (node);
                    while ((i < n) && (path == null)) {
                        path = search ((DefaultMutableTreeNode) model.getChild (node, i), object);
                        i ++;
                return path;
        private class SearchPanel extends JPanel {
            public SearchPanel () {
                JTextField searchField = new JTextField (10);
                searchField.addActionListener (new ActionListener () {
                    public void actionPerformed (ActionEvent event) {
                        treePanel.searchAndExpand (((JTextField) event.getSource ()).getText ());
                setLayout (new GridBagLayout ());
                add (searchField, new GridBagConstraints ());
        public static void main (String[] parameters) {
            new Test ();
    }Kind regards,
      Levi

  • Output type Requirement triggering

    Hi,
    In my project I have a requirement to stop triggering of an output type if all the items in the sales order have reason for rejection set.
    I have done the condition check in a output requirement routine and if the condition fails then I set SY-SUBRC = 4.
    Problem 1:
    But when I am creating the sales order, the komkbv1 structure does not have the sales order no. (it has other fields) and kompbv1structure is not filled. Then how do I check if all the items have Reason for rejection set or not.
    Problem 2:
    For an existing sales order, I trigger the output type in Header-->Output... , this code is getting executed and sy-subrc is set to 4. But still the output is triggered.
    Please let me know how do I proceed.
    Code:
    w_vbeln = komkbv1-vbeln.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT         = w_vbeln
    IMPORTING
       OUTPUT        = w_vbeln .
    Atleast one item of the Sales Order does not have
    reason for rejection set.
    select single * from VBAP
    where vbeln = w_vbeln and
          ABGRU eq space.
    if sy-subrc ne 0.
       sy-subrc = 4.
       EXIT.
    endif.
    Thanks in advance,
    Vishnu Priya

    Hi,
    For the first problem,
      Check the standard structures available, but not sure.
    For the Second one,
      You routine include should be included in the standard include RV61BNNN
    for it to get triggered.
    Your routine will not get executed if your routine is not included in this standard include.
    Hope this helps.

  • How do show JTree DnD drop location with custom TreeRenderer?

    I am adding DnD support to a JTree with a custom renderer.
    With the custom renderer I am losing the display of drop location on the tree.
    Is there a method to determine if the passed in node object in the getTreeCellRendererComponent is currently a drop location?
    I can tell if the node is selected, but not if a DnD is in action on the tree.
    Thanks,
    Chris

    Is there a method to determine if the passed in node object in the getTreeCellRendererComponent is currently a drop location?
    I can tell if the node is selected, but not if a DnD is in action on the tree.If you are using Java 1.6 you should be able to do something along these lines:Install a TransferHandler on your tree, and override the method canImport() that takes a TransferHandler.TransferSupport as input argument. That method is called repeatedly during the drag process.
    In that method, ask the passed in TransferSupport for the current drop location, by calling getDropLocation(). For a JTree that will return a JTree.DropLocation, which in turn has methods for finding out which node is the current drop target. Store that node in a variable that your renderer can access.

  • Exporting using exp and TRIGGERS=N doesn't  work

    Exporting using exp on version Export: Release 8.1.6.0.0 - with the option TRIGGERS=N stills exports with triggers. is it a bug ?
    Any sugesttions ?

    This is actually a known behaviour.
    As of table level export, all the dependent objects are exported and is expected namely, indexes, constraints, triggers... and even restricting with other parameters set to n will not disable their export.
    As of schema level export, the whole schema is exported and with this we can pose our restrictions like no constraints, no rows, no indexes, no triggers etc.. which will work because we have control.
    For table level export we dont have control on individual objects. 10g solves your problem.

  • Would RollBacks For Stateless Session Beans work In case of Stored Procedures or Triggers Written in Oracle PL/SQl

              We are writing a J2EE application and using Weblogic 5.1 on Unix machine. We are
              considering writing some Stored Procedures or Triggers on Oracle DBMS. Hence our
              Stateless Session Beans / Data Access Objects (DAOs) would be calling those stored
              procedures, which would reside on Oracle 8.1.7 (on Windows 2000). (These Data
              Access Objects are running under the umbrella of a Stateless Session Beans). We
              are using WebLogic's Connection Pooling.
              Our question is: Would we get reliable rollbacks from our stored procedures. I
              mean would the Transaction Management process of the EJB container work. Remember
              the SQL is written in the Database (Oracle in this case) in the form of Stored
              Procedures / Triggers through PL/SQL.
              Any ideas or tips would help.
              

              I would agree with Cameron Purdy. Be very cautious to use Oracle specific
              Triggers / Stored Procedures. Consider following, (apart from what he said):
              1. Unreliable behaviour of the Oracle JDBC drivers, specially 8.1.6 family..
              (You may visit the Oracle's web site and see the newsgroups for the JDBC drivers).
              This is enough of a reason to stop right there.
              However for interest sake you may consider following issues:
              2. By use of Oracle specific Triggers / SPs the application will not be portable.
              Vendor Lock In. Remember your choice for J2EE compliant Server (WebLogic in this
              case). The whole purpose would be defeated by going for this option.
              3. There are issues related to the extensibility of the application. I have
              my reservations and would hold my breath on two phase commit protocol transactions
              being reliable in this scenario.
              Have fun...
              Terry
              "Cameron Purdy" <[email protected]> wrote:
              >Yes, the work performed by the SPs and the triggers would be in the same
              >tx.
              >
              >What would NOT work is if the data has been read into WebLogic and then
              >it
              >gets affected by a trigger or SP on the RDBMS, the data in WebLogic is
              >not
              >automatically re-read within that same tx so you need to be careful.
              >
              >Peace,
              >
              >--
              >Cameron Purdy
              >Tangosol Inc.
              >Tangosol Coherence: Clustered Coherent Cache for J2EE
              >Information at http://www.tangosol.com/
              >
              >
              >"Ahmad" <[email protected]> wrote in message
              >news:[email protected]...
              >>
              >> We are writing a J2EE application and using Weblogic 5.1 on Unix machine.
              >We are
              >> considering writing some Stored Procedures or Triggers on Oracle DBMS.
              >Hence our
              >> Stateless Session Beans / Data Access Objects (DAOs) would be calling
              >those stored
              >> procedures, which would reside on Oracle 8.1.7 (on Windows 2000). (These
              >Data
              >> Access Objects are running under the umbrella of a Stateless Session
              >Beans). We
              >> are using WebLogic's Connection Pooling.
              >> Our question is: Would we get reliable rollbacks from our stored
              >procedures. I
              >> mean would the Transaction Management process of the EJB container
              >work.
              >Remember
              >> the SQL is written in the Database (Oracle in this case) in the form
              >of
              >Stored
              >> Procedures / Triggers through PL/SQL.
              >> Any ideas or tips would help.
              >
              >
              

  • ORA-30511: invalid DDL operation in system triggers

    Hi,
    I am calling a procedure in a Trigger.
    In that Procedure EXECUTE IMMEDIATE is used to CREATE a table.
    But when The Trigger is firing its giving Error as :ORA-30511: invalid DDL operation in system triggers
    Kindly any help will be needful for me

    user598986 wrote:
    Hi,
    I am calling a procedure in a Trigger.
    In that Procedure EXECUTE IMMEDIATE is used to CREATE a table.
    But when The Trigger is firing its giving Error as :ORA-30511: invalid DDL operation in system triggers[I thought I already explained it|http://forums.oracle.com/forums/message.jspa?messageID=3379456#3379683]. And again, granting privileges dynamically in a logon trigger is a very bad design. If you want to stick to it, you could schedule a job in trigger, as Timur suggested, however keep in mind, job runs asynchronously, so trigger will have to wait for the job to finish. Otherwise there might be a gap where session would not have privs granted yet.
    SY.

  • Create background job triggered by another job

    Hi experts,
    I want to run FCHU in background everytime I finished run F110.
    I'm thinking to use background job creation SM36 - triggered by job. But the problem is, job created from F110 the job name is not fixed.
    Please anyone can give better idea ??
    Thanks,
    Melissa

    Hi melissa,
    The suggestion given by Prem is perfectly Ok.
    I would suggest you to create an event  by sm62 and then create an event triggered  background job which will run the FCHU in Back ground.
    So you need to get an enhancement point in F110 and put the code of triggering the event .
    If there is no enhancement  then you can create a program which will call the Transaction F110 by using CALL TRANSACTION statement and after F110 processing the control will get back to your program and you can write a code for triggering the event by using the FM SWE_EVENT_CREATE.
    I hope this will help you

  • Triggering a mail when ever a perticular inbound IDOC fails

    Hi Experts,
          Is there any way I can trigger mails whenevr an inbound idoc fails to update in r3.With reference to workflow etc
    Regards,
    Arnab

    hi,
    i think u need to check tcode swu3 for automatic workflow customizing and check in we40 (error AND STATUS PROCESSING) whether the processing code is assigned to the workflow task.
    if it is assigned,the workflow will be automatically triggered and the mail will be sent to the user by itself.
    ALE error handling uses workflow. A standard task is provided for each message type. Task TS20000051 is used for all BAPIs.
    Workflow functions as follows:
    A task (work item) is generated for the error handling and stored as a message in the inboxes of the employees responsible.
    If one of these employees processes the work item, the standard task method for error handling is started. The user can, for example, restart IDoc processing.
    If the IDoc is processed successfully, the work item is deleted from the inboxes of all the employees involved.
    For this procedure to function, the employees responsible for a particular message type and partner (sender or receiver) must be defined as follows:
    1. A hierarchy of organizational units (for example, "sales office") and positions (for example, "customer officer for customer X") is created and employees are assigned to it.
    2. The standard tasks for error handling (for example, an error related to an inbound sales order) are assigned to the relevant organizational units or positions (for example, "sales office").
    3. The organizational unit, position or employee responsible for dealing with the error are specified for each partner and message type in the partner profiles.
    If an error occurs, the system determines:
    1. The employees responsible using the staffing schedule of the organizational unit or position linked to the standard task.
    2. The employees defined in the partner profiles (using position, user ID, or organizational unit).
    3. The employees appearing in both groups represent those who will receive a work item in their inboxes.
    regards,
    pankaj singh

  • Output type triggering multiple times.

    Hello All,
    I have a PO output type configured with multiple issuing setup and it shoots mail to my inbox with PO details.
    My concern is: I could see the output type triggered only 2 times,but i have received more than 5 mails in my Inbox.
    How is this happening? I checked with the spool history n all. i couldn't find any loop holes.
    Do anyone have any suggestions of where can i check further.
    Thanks
    Dhilipan

    Hi,
    Goto SOST - Transmission Request to see how many times message has been triggered. Hope it will give u some idea.
    Regards,
    Ram

  • Triggers not retrieving expected data

    Hi,
    Need some help with triggers here.
    In Table A, for example, it has columns Col1(Varchar2), Col2(Date).
    And there are these triggers on table A:
    1. trigger 1: insert or update, before each row
    - to set :NEW.COL2 := SYSDATE
    2. trigger 2: update on col1, before each row
    - insert into table B with one of the values :NEW.COL2
    3. trigger 3: update on col1, before each row
    - insert into table C with one of the values :NEW.COL2
    This is the behaviour I see for table A in my system:
    Col1 Col2
    data1 14/3 12:00 => Record inserted
    data2 17/3 14:00 => Record get updated to data2
    trigger 1, updates the date from 14/3 to 17/3.
    trigger 2, the value of :NEW.COL2 is 17/3.
    trigger 3, the value of :NEW.COL2 is still 14/3.
    Can someone help to explain why this is happening? Or is there any workaround? In the trigger 3 i need to see the new value 17/3. I cannot amend trigger 1 or 2 either.
    Thanks in advance!

    Note that the order of execution or more than one trigger of same type on the same table is not guranteed.
    Same type triggers on the table will execute in some order that cannot be specified. What you are seeing is the expected and documented behaviour.
    You would need to consolidate these different triggers of same type into one to avoid any such issues.

  • How to keep the cellEditor after remove/add table columns

    The cellEditor/render will be invalid after fireTableStructureChange event. How to make the cellEditor work properly as before the structure changed?

    After a fireTableStructureChange event the TableColumnModel is recreated and the default renderers and editors are used. If you are using custom renderers or editors you need to reinstall them for the appropriate column.

  • Level triggered Integrator

    Hello
    In Control Design and Simulation there is Rising / Falling edge reset input for Integrator, is there any way I can design level triggered Integrator ?
    It will be great if this small thing can be explained in some VI
    Thanks in advance.
    Thanks & Regards,
    Kunal Raithatha.
    CTD - CLAD (I wish I can take off that A, and maybe use it later to replace D :-)
    Easy Tip :- "To copy an image to a VI icon, drag the image file and place it on the icon
    located in the upper right corner of the front panel or block diagram" ...If you know any
    more reply back.

    There may be a way to write some code that accomplishes this task.
    Help me understand a little bit more about how this integrator would behave. Is there some standard to define how a level-triggered integrator should behave, or do you get to make up the rules? What would constitute a level signal? Would the integrator reset as soon as it received two or three equivalent values for the reset input on subsequent timesteps? Would it continue to reset until the signal changes, or would it only reset at the start of the level signal?
    Give me all the info you can and I'll try to help you find a way.
    Cheers,
    Damon

  • How to set Jtree Nodes' name into TextField??

    Dear Sir:
    I have following code to select any file's name then put into TextField,
    see:
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.io.File;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextField;
    import javax.swing.JTree;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.TreePath;
    public class JTreeSplitChooseDemo extends JPanel implements ActionListener{
        JFileChooser fc;
        JButton openButton, saveButton;
        JTextField jtf;
      public JTreeSplitChooseDemo() {
        final JTree tree;
        final JTextField jtf;
        JPanel jp= new JPanel();
        setPreferredSize(new Dimension(500,350));
        jp.setPreferredSize(new Dimension(500,300));
        DefaultMutableTreeNode top = new DefaultMutableTreeNode("Options");
        DefaultMutableTreeNode a = new DefaultMutableTreeNode("A");
        top.add(a);
        DefaultMutableTreeNode a1 = new DefaultMutableTreeNode("A1");
        a.add(a1);
        DefaultMutableTreeNode a2 = new DefaultMutableTreeNode("A2");
        a.add(a2);
        DefaultMutableTreeNode b = new DefaultMutableTreeNode("B");
        top.add(b);
        DefaultMutableTreeNode b1 = new DefaultMutableTreeNode("B1");
        b.add(b1);
        DefaultMutableTreeNode b2 = new DefaultMutableTreeNode("B2");
        b.add(b2);
        DefaultMutableTreeNode b3 = new DefaultMutableTreeNode("B3");
        b.add(b3);
        tree = new JTree(top);
        JScrollPane jsp = new JScrollPane(tree);
        jsp.setPreferredSize(new Dimension(500,300));
        tree.setPreferredSize(new Dimension(500,300));
        add(jsp, BorderLayout.CENTER);
        jtf = new JTextField("", 20);
        add(jtf, BorderLayout.SOUTH);
        tree.addMouseListener(new MouseAdapter() {
          public void mouseClicked(MouseEvent me) {
            TreePath tp = tree.getPathForLocation(me.getX(), me.getY());
            if (tp != null)
              jtf.setText(tp.toString());
            else
              jtf.setText("");
      public JPanel JTreeText() {
             JPanel jp= new JPanel();
             JPanel jpanel= new JPanel();
             setPreferredSize(new Dimension(400,350));
             jp.setPreferredSize(new Dimension(400,300));
             JScrollPane jsp = new JScrollPane(jp);
             jsp.setPreferredSize(new Dimension(400,300));
             jpanel.add(jsp, BorderLayout.CENTER);
             jtf = new JTextField("", 20);
             fc = new JFileChooser();
             openButton = new JButton("Open a File...",new ImageIcon("images/hui.gif"));
             openButton.addActionListener(this);
             JPanel buttonPanel = new JPanel(); //use FlowLayout
             buttonPanel.add(openButton);
             //jp.add(buttonPanel, BorderLayout.PAGE_START);
             jp.add(buttonPanel, BorderLayout.NORTH);
             jp.add(jtf, BorderLayout.CENTER);
             return jpanel;
      public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.getContentPane().add(new JTreeSplitChooseDemo(), new BorderLayout().WEST);
        frame.getContentPane().add(new JTreeSplitChooseDemo().JTreeText(), new BorderLayout().CENTER);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(800, 350);
        frame.setVisible(true);
    @Override
    public void actionPerformed(ActionEvent e) {
         //Handle open button action.
        if (e.getSource() == openButton) {
          int returnVal = fc.showOpenDialog(JTreeSplitChooseDemo.this);
          if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
             jtf.setText(file.getName());
          } else {
             jtf.add("Open command cancelled by user.", null);
    }For example, If i choose file : C:\temp\ftp\TestMyFile.txt
    after I press open button, then choose it, then, the file name TestMyFile.txt will be displayed in the textFiled.
    My problem is that I hope to choose any node in the JTree on the left Panel, then when I choose it, this JNode I selected will be displayed its name in the TextField.
    Not file, I need choose JNode,
    ie, B1 under B node, or A1 under A node, then B1 will be displayed in jtf.
    How to do this one??
    Can Guru throw some light??
    Thanks
    sunny

    Thanks, camickr.
    My fault not to explain detail.
    Actually I mean that I will use a dialog box(very much look like a file choose) that is something like a file chooser then I can browse over JTree first for any node then I can choose or select a node in this JTree, after select this node, its name is populated into text field. My one is I will use a JTree browser (something like that) to get a tree node.
    ie, this showOpenDialog will browse over JTree, not File system.
    I did not want to click on the node then this node name is populated into textField.
    the sample (http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html) shows that when I select a node, then its name was populated to a destination.

  • JTree from root

    If a TreeNode has been set as the root of a JTree, is there any method that will recover the JTree from the TreeNode (other than just coding the info into the program's data when you set the node as root)?

    I managed to come up with a pair of jtree/node classes that do what I want, e.g. node.addNotify(newChild) causes the jtree display to update; I think this is better than node.add(newChild);<something update the jtree display> on the basis that `an intelligent object moves complexity from the many to the few'(Cline & Lomow _C++ FAQS+ p 42).  I'm just surprised that this isn't made easier to do.

Maybe you are looking for

  • Error 10 occurred at New VI Library.vi when building .exe

    This is driving me crazy!  What is causing this.  The program worked fine in 8.5.1 and before.  The only thing that has changed is that I had to create directories for each class in the Microsoft Report Generation Toolkit which was a huge pain itself

  • Every time I try to create a new button I get "photoshop file error -1"

    I'm creating a BluRay set of discs. I'm on number 4 and there will probably be 12. I use the previous discs as a template for the new ones to save huge amounts of time. I haven't had an issue till I opened my project today. Usually I right click on a

  • Setup Raid and installing Windows Vista - P965 Neo-f

    I hope someone can help.... I bought this motherboard along with all the other items required to build a new system as follows: MSI P965 Neo-f motherboard (Bios v1.5) Intel Core 2 Duo E6600 2gb (2 x 1gb) OCZ PC-6400 (800) Memory 2 x 200gb Hitachi Har

  • ODP 9.2.0.7 and Database 10g (10.2.0.5)

    Hello everybody. I wanted to know if it is possible to use ODP 9.2.0.7 against a 10g (10.2.0.5) database. Up to this moment, one of our customers has an application with a 9.2.0.7 database that uses the 9.2.0.7 ODP. Some years ago, the development te

  • Calendar Crashes on connection loss.

    Does anyone know why oracle calendar crashes when the connection to the calendar server is lost. This happens for both Mac and Windows. I am using calendar version 9.0.4.2