Jtree and checkboxes again

hi there !
I'm trying to build a jtree with jcheckboxes.
But, how do I set/access the (selected) jcheckboxes ?
The selected nodes should be used to generate a DB-query ... how can I get an elegant mapping between the unique identfiers and the nodes ?
Currently I'm using the editor and renderer from
http://saloon.javaranch.com/2/001095.html
(bottom of the page)

reply #10 of the posted link shows you how you can create a JTree with JCheckBox...., if that isn't what you're looking for, I must have misunderstood your question!
;o)
V.V.

Similar Messages

  • Displaying a jtree with checkboxes and enabling some default checkboxes

    I have created a jtree displaying a list of nodes hierarchically ,and created a checkbox for each node as well.
    My problem is having created the jtree with checkboxes i need to have some of the nodes in the hierarchy checked by default on first launch of the gui.To do this i read a list of treepaths from a file and would want to traverse the tree and enable the node after finding it,which is what i am having issue with.
    Your solution would be appreciated as i am a newbie and having got this far, feel like i need some back up :)
    Thanks & Regards
    Shashi

    I have created a jtree displaying a list of nodes hierarchically ,and created a checkbox for each node as well.
    My problem is having created the jtree with checkboxes i need to have some of the nodes in the hierarchy checked by default on first launch of the gui.To do this i read a list of treepaths from a file and would want to traverse the tree and enable the node after finding it,which is what i am having issue with.
    Your solution would be appreciated as i am a newbie and having got this far, feel like i need some back up :)
    Thanks & Regards
    Shashi

  • Focus Problem with JTree and Menus

    Hi all,
    I have a problem with focus when editing a JTree and selecting a menu. The problem occurs when the user single clicks on a node, invoking the countdown to edit. If the user quickly clicks on a menu item, the focus will go to the menu item, but then when the countdown finishes, the node now has keyboard focus.
    Below is code to reproduce the problem. Click on the node, hover for a little bit, then quickly click on the menu item.
    How would I go about fixing the problem? Thanks!
    import java.awt.Container;
    import java.awt.GridLayout;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JTree;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeModel;
    public class MyTree extends JTree {
         public MyTree(DefaultTreeModel treemodel) {
              setModel(treemodel);
              setRootVisible(true);
         public static void main(String[] args) {
              JFrame frame = new JFrame();
              JMenuBar bar = new JMenuBar();
              JMenu menu = new JMenu("Test");
              JMenuItem item = new JMenuItem("Item");
              menu.add(item);
              bar.add(menu);
              frame.setJMenuBar(bar);
              Container contentPane = frame.getContentPane();
              contentPane.setLayout(new GridLayout(1, 2));
              DefaultMutableTreeNode root1 = new DefaultMutableTreeNode("Root");
              root1.add(new DefaultMutableTreeNode("Root2"));
              DefaultTreeModel model = new DefaultTreeModel(root1);
              MyTree tree1 = new MyTree(model);
              tree1.setEditable(true);
              tree1.setCellEditor(
                   new ComponentTreeCellEditor(
                        tree1,
                        new ComponentTreeCellRenderer()));
              tree1.setRowHeight(0);
              contentPane.add(tree1);
              frame.pack();
              frame.show();
    import java.awt.FlowLayout;
    import java.util.EventObject;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.JTree;
    import javax.swing.tree.DefaultTreeCellEditor;
    import javax.swing.tree.DefaultTreeCellRenderer;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.TreeCellEditor;
    import javax.swing.tree.TreeCellRenderer;
    public class ComponentTreeCellEditor
         extends DefaultTreeCellEditor
         implements TreeCellEditor {
         private String m_oldValue;
         private TreeCellRenderer m_renderer = null;
         private DefaultTreeModel m_model = null;
         private JPanel m_display = null;
         private JTextField m_field = null;
         private JTree m_tree = null;
         public ComponentTreeCellEditor(
              JTree tree,
              DefaultTreeCellRenderer renderer) {
              super(tree, renderer);
              m_renderer = renderer;
              m_model = (DefaultTreeModel) tree.getModel();
              m_tree = tree;
              m_display = new JPanel(new FlowLayout(FlowLayout.LEFT));
              m_field = new JTextField();
              m_display.add(new JLabel("My Label "));
              m_display.add(m_field);
         public java.awt.Component getTreeCellEditorComponent(
              JTree tree,
              Object value,
              boolean isSelected,
              boolean expanded,
              boolean leaf,
              int row) {
              m_field.setText(value.toString());
              return m_display;
         public Object getCellEditorValue() {
              return m_field.getText();
          * The edited cell should always be selected.
          * @param anEvent the event that fired this function.
          * @return true, always.
         public boolean shouldSelectCell(EventObject anEvent) {
              return true;
          * Only edit immediately if the event is null.
          * @param event the event being studied
          * @return true if event is null, false otherwise.
         protected boolean canEditImmediately(EventObject event) {
              return (event == null);
    }

    You can provide a cell renderer to the JTree to paint the checkBox.
    The following code checks or unchecks the box with each click also:
    _tree.setCellRenderer(new DefaultTreeCellRenderer()
      private JCheckBox checkBox = null;
      public Component getTreeCellRendererComponent(JTree tree,
                                                    Object value,
                                                    boolean selected,
                                                    boolean expanded,
                                                    boolean leaf,
                                                    int row,
                                                    boolean hasFocus)
        // Each node will be drawn as a check box
        if (checkBox == null)
          checkBox  = new JCheckBox();
          checkBox .setBackground(tree.getBackground());
        DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
        checkBox.setText(node.getUserObject().toString());
        checkBox.setSelected(selected);
        return checkBox;
    });

  • Is it possible to have sorting by group and checkboxes in the same ALV

    Hi there,
    Does anyone know whether it is possible to have sorting and group on one field in ALV and checkboxes set on another field in ALV?
    eg.
    Fieldname
    ===========
    Name----
    Text
    Allowance----
    Numeric -> Sort & Group
    Verified----
    Checkbox
    How do I code it if it is possible to have grouping and check box all in one ALV.  Meaning I want some data that are the same to merge using sort, while still having the checkbox available for my other field (Verified).
    Thanks in advance.
    Lawrence

    hi,
    GROUP BY clause is used on database tables with select statement.
    sort is used on internal tables.
    can u clearly explain y u need group by and sort on the same field.
    if u are extracting from dbtable using grou by clause on a field, then no need to sort it again.
    if u want sort u can do it by giveing "sort itab by field". thats not a problem.
    now coming to check box.instead of using SLIS type field catalog, u use LVC type.
    in LVC_S_LAYO, u can fine box_fname.
    while defining layout, u declare a variable of type LVC_S_LAYO
    AND GIVE BOX_FNAME = internal table field name

  • Using JTree with checkbox

    Hi All,
    I have a link for implementation of JTree with Checkbox
    http://www.jroller.com/santhosh/date/20050610 He has implemented exactly what i want but i am unable to understand the use of all the classes. Really difficult to understand
    So what i did was create a few objects with Checkbox class from AWT package and then added then to JTree using the DefaultMutableTreeStruture i got the tree working but not able to get the Checkboxex
    Can any one explain me how i can implement this senario
    I am trying different search creterias but unable to find a right detailed explanation to my query
    Rgds
    Aditya

    where did you find DefaultMutableTreeStructure?

  • Can we edit the input payload and resubmit again from BPM worklist app.

    hi friends,
    can we edit the input payload and resubmit again from BPM worklist applications.
    please provide me any links on this.
    Thanks,

    Hi ,
    Dont know what you mean by resubmit but, you can surely modify the input data from inside BPM Worklist before submitting.
    Follow Section 15.6.4 Specifying the Task Payload Data Structure in the below link :
    http://download-uk.oracle.com/docs/cd/B31017_01/integrate.1013/b28981/workflow.htm#BABFICJF
    Make sure to select "Modifiable via Worklist App" checkbox.
    thanks
    Saurabh

  • ItemUpdated and CheckBox

    I have a datagrid filled from a RO. There are a bunch of form fields outside of the Datagrid. When I press on a record the fields get filled in. That works perfect. One of the fields is a combobox. So I change some things in the fields and do an update. I update a DB and also use the itemUpdate to keep everything matching the screen to the DB. When I click to another record and then back the fields are changed and most all is perfect. The only thing I cannot do is get the Checkbox to Update. I press on the checkbox press an update button and the click to another record and then back and the checkbox does not show me if I selected "true" The DB updates just the Checkbox does not represent the data.
    This is fired when the update button is pressed:
    public function updateVehicle():void {
            if (mainList.selectedItem !== null) {
                vehicleList.setItemAt({ID:ID.text, Vin:Vin.text,
                    State:State.text,
                    Plate:Plate.text,
                    BrandID:BrandID.text,
                    BrandID2:BrandID2.text,
                    DrCheck:DrCheck.selected,
                    PsCheck:PsCheck.selected
                    }, mainList.selectedIndex);
                    sendFormdata();
                    var currentlySelectedItem : Object = mainList.selectedItem;
              currentlySelectedItem.Vin =  Vin.text;
              currentlySelectedItem.State =  State.text;
              currentlySelectedItem.Plate =  Plate.text;
              currentlySelectedItem.Brand =  BrandID.text;
              currentlySelectedItem.Brand2 =  BrandID2.text;
              currentlySelectedItem.DrCheck =  DrCheck.selected;
              currentlySelectedItem.PsCheck =  PsCheck.selected;
              vehicleList.itemUpdated(currentlySelectedItem);
              Alert.show("The database has been updated.")
    DrCheck and PsCheck are the id's of the checkboxs. the Brand and Brand2 are comboboxs (works great) and the rest are textinputs. I know I asked a very similar question the other day. Once you get one thing (2 days) 5 minutes goes by and stuck again. If I didnt love CF and Flex so much Id hate it.
    Thanks
    George

    On my original post has the update function that gathers the fields data to send to an update function, the second half of the function does the the itemUpdate. The BrandID and BrandID2 are for the comboboxs and the DrCheck and PsCheck are for the Checkboxs:
    <mx:ComboBox id="BrandID" prompt="Select a Brand" dataProvider="{newBrands}" selectedItem="{BrandID.text}" labelField="label" width="150"
                 themeColor="#73B9B9"/>
    <mx:CheckBox label="Pending" id="DrCheck" themeColor="#73B9B9"/>
    When the program first loads I can pick in a DG and it changes the ComboBox to match whats in the ArrayCollection. That part is working. The Checkbox does not. Seems like I have it right, just does not get the true false values back into the collection. So when I make a change like check a box and press update the DB updates but if I leave the row and then select back on the first record the checkbox is always false, unless I reload all the data.
    Thanks
    G

  • Problem: There is not enough disk space available to process clips. Clear some space and try again.

    Hi there.
    I am running the newest FCPX 10.0.9 and Mavericks, and I am editing a large multicam project. I have approx. 190 GB left on my external event/project disk via USB3 (it has 2TB in total), and I get the error message:
    "There is not enough disk space available to process clips. Clear some space and try again."
    when I am trying to add clips to an angle in one of my multicam clips. I have made more than 8 multicam clips in the same event, without that problem, but now it won't let me add more.
    What's the problem?

    This was driving me nuts as well until I found the sneaky checkbox. In the editing tab in Preferences there is a checkbox for "Optimize media for multicam." If that's checked, Final Cut is rendering ProRes files for every clip you bring into multicam, so it just eats memory. Unchecking that solved my issues; hope it helps you or anyone who comes across this!

  • Mail applications is blank when I open it, then it closes and opens again by itself, keeping blank

    In my Ipad, when I open Mail application it is blank. It stays like this for a few seconds, then it closes and open again by itself.  Keeping all time blank.

    Have you tried to force quit the app. Double tap the home button. Scroll sideways if needed to bring the mail app preview up on the screen. Flick that preview up and off the screen to close the app. Tap on the home page preview to exit the mode. Then try your mail again.
    Other things people have needed to do, especially after an update is to go into the settings, mail contacts and calendars, delete their mail account (it only deletes it off the iPad not out of existence) then exit out, go back i and re-enter the info.

  • I am on windows 7 and I upgraded to 10.0.2 and now it will not open. I have removed firefox completely and uploaded it again and that did not work. So my latest attempt I removed firefox 10 again and uploaded the beta version and once again nothing.

    I am on windows 7 and I upgraded to the newest verison of firefox and now it will not open. I have removed firefox completely and uploaded it again and that did not work. I then made sure it could get through my firewall and that did not work. So my latest attempt I removed firefox 10 again and uploaded the beta version hoping that would do it and once again nothing. It will not open at all. Please help - is there a live chat or a number to talk to someone at Firefox?

    I think when uninstalling you may also have to choose (tick) to delete the preferences and other personal data like the bookmarks, stored passwords etc. to erase completely. If you are installing afresh, please try right-clicking on the file and '''Run as administrator''' to install. And when uninstalling, please also make sure choose to delete all data and also manually delete any '''Mozilla''', '''Mozilla Firefox''' or '''Firefox''' from %appdata%, %localappdata% and %programfiles%. You can open a location by typing for eg. %appdata% in the '''Run''' box (Windows key + R). You may also have to check the '''VirtualStore''' folder in %localappdata%. Files in the VirtualStore can be problematic. I think a clean installation may help.
    [https://www.mozilla.org/en-US/firefox/new/ Firefox]
    [http://kb.mozillazine.org/Installation_directory Installation Folder]
    [http://kb.mozillazine.org/Profile_folder Profile Folder]
    Please note that using system restore would usually damage the Firefox installation.

  • Is there a way to create an e-mail template to send over and over again to different people?

    Can I create a template and use it over and over again? I found where I was able to save an e-mail as a template but I cannot find where to access it to be able to send it.

    Read this.
    http://kb.mozillazine.org/Thunderbird_:_FAQs_:_Using_Templates

  • Getting error while creating a new web app saying "The password supplied with the username domainname\username was not correct. Verify that it was entered correctly and try again"

    Hi ,
    I am trying to create a new web app using Central Administration in Sharepoint 2010 and getting an error "The password supplied with the username  was not correct. Verify that it was entered correctly and try again".
    I tried running this command also "stsadm -o updatefarmcredentials -userlogin <domain\username> -password <newpassword>" but when it got executed it showed me "Access Denied".
    What should i do ??
    Thanks in advance.
    Regards, Anurag

    HI,
    right click on command icon and click run as administrator then use above stsadm commend to update credential. If still you face same issue then try with powershell as mention in below link: (make sure that you open sharepoint powershell as run as administrator)
    http://smartrider.wordpress.com/2010/07/15/powershell-script-to-create-web-application-and-site-collection-in-sharepoint-2010/
    let us know your result
    Hemendra: "Yesterday is just a memory,Tomorrow we may never see"
    Whenever you see a reply and if you think is helpful, click "Vote As Helpful"! And whenever
    you see a reply being an answer to the question of the thread, click "Mark As Answer

  • "there is a problem with adobe acrobat/reader. if it is running please exit and try again. (523.523)

    We are getting the following error "there is a problem with adobe acrobat/reader. if it is running please exit and try again. (523.523)" and a gray screen appears (Image not viewable) with multiple users. We are using Adobe Reader XI (11.0.05) and (11.0.06). The current workaround is to log off the website and log back in. Once the user logs back in, the pdf will appear. However it occurs anywhere from 2-8 times in a day. Anyone else having this issue or know of another workaround? Any suggestion with how to fix? Please help!!

    Hi Valerie,
    Please let me know the version of Adobe Acrobat/Reader & operating system installed on your computer?
    Also, try this:-
    Launch Adobe Reader/Acrobat.
    From the menu, choose Edit -> preferences -> General
    Uncheck the option for "Enable Protected Mode at startup"
    Restart the Adobe Reader and web browser.
    Regards,
    Aadesh

  • Cannot send or receive yahoo mail or gmail from iPhone . installed ios 6 recently. tried rebooting the phone and deleting the email account and adding again but nothing works ! can someone suggest a solution?

    cannot send or receive yahoo mail or gmail from iPhone . installed ios 6 recently. tried rebooting the phone and deleting the email account and adding again but nothing works ! can someone suggest a solution?

    Not sure about yahoo, but for gmail, I done the following:
    Set up using Exchange on iPhone, it'll keep prompting for password.  On PC use captcha option, log in to gmail account from PC after completingg captcha option, enter password on iPhone.
    See how that goes for gmail, let us know.
    Hopefully someone will have fix for yahoo.

  • Couldn't find root user.  Sleeping and trying again.

    Last week I installed an MSO 2004 update on my G5 iMac running 10.4.11.
    Then I attempted to repair permissions. The repair permissions process
    halted at about half of the progress bar. I let it cook for about two
    hours without success, then tried to force quit Disk Utility. I
    couldn't force quit it, so I very reluctantly turned off the Mac;
    something I've rarely ever done. I waited five minutes and then turned
    the Mac back on. The startup sequence progressed to the point where the
    system displays the gray apple on the gray background, and the circular
    progress indicator or gear begins turning. I let it turn for one hour
    and then powered off the iMac, then powered it back up with the same
    results.
    I powered it off again and then commenced a Safe Boot. Same results as
    before.
    I powered it off again and then started it in Single User Mode. No
    problem. I ran /sbin/fsck -fy. No problem.
    I typed "reboot" and it rebooted. This time I start it in Verbose mode.
    After the preliminary startup code, the system began repeating the same
    message lines:
    dsFindDirNodes returned -14071, count = 0 count = 2147483646
    Couldn't find root user. Sleeping and trying again.
    A Google search produced very few results. I don't have a backup
    because I inherited this iMac from my 75 year old semi retired father
    who wanted a 20-inch Intel iMac instead. I just goof around with the G5
    iMac from time to time, and am considering giving it to my little niece and
    nephews. It worked great for about a month. I have customized my
    user account and the accounts for the little ones, so I really don't
    want to wipe the hard drive and reinstall Tiger again from scratch.
    I booted from the suspect internal hard drive into single user mode.
    I ran /sbin/fsck -fy on the internal hard drive.
    All tests passed.
    I ran fsck_hfs on the internal hard drive.
    It returned a message that stated that I needed
    to add additional information.
    I ran fsck_hfs with several switches enabled, but
    it continued to return this message.
    I performed the procedures in Apple's article 107210
    "Mac OS X, Mac OS X Server: How to Replace the NetInfo
    Database (Restoring from defaults).
    This did not solve the problem.
    I booted this computer from my external Firewire hard drive that I use
    to create nightly backups on my G4 iMac using SuperDuper!.
    I ran Disk Utility Repair Disk Permissions on the
    internal hard drive.
    There were no permissions errors.
    I ran Disk Utility Repair Disk.
    All tests passed.
    I ran the TechTool Pro Suites --> Advanced Tests on
    the internal hard drive.
    All tests passed except for "Startup File" which it
    listed as " <Not Present>".
    The description of this test is:
    "This test checks the Startup file. The parameters
    within this file contain the information used by
    the computer ROM to determine what program will
    boot the computer as well as other system-specific
    aspects."
    I ran the TechTool Pro Performance --> Maintenance
    routine on the internal hard drive.
    It completed the maintenance successfully.
    I ran DiskWarrior on the internal hard drive.
    It reported no directory errors, but I replaced it
    anyway.
    While booted from the external Firewire hard drive, I viewed what
    appears to be the proper compliment of folders on the internal hard
    drive. Of course, I didn't examine and verify every subfolder in the
    hierarchy, however, examining the Applications, Library, System, and
    Users folders two deep seemed to indicate that everything was there.
    I booted this computer from my Tiger installation disk. I selected
    Utilities --> Reset Password... (I think.). It listed only the
    Administrator account (root) on the internal hard drive. It did not
    list the other three accounts that I created on this hard drive, even
    all three respective folders are present in the Users folder. However,
    it did list all four accounts on the still attached external Firewire
    hard drive.
    By every measure, this drive and its directory are sound. I am
    concerned that TechTool Pro reported that the Startup File is Not
    Present. Beyond the meaning that the words suggest, I'm not sure what
    this really means. I checked the Micromat site and found the following:
    The Startup File has been defined but not yet
    implemented by Apple.
    What does the message signify:
    dsFindDirNodes returned -14071, count = 0 count = 2147483646
    Couldn't find root user. Sleeping and trying again.
    Can I effect a simple repair?
    Thank you.

    I think besides a reinstall, only DiskWarrior from Alsoft...
    http://www.alsoft.com/DiskWarrior/
    stands a chance of fixing it.

Maybe you are looking for

  • How to add a radio station to the library

    just loaded itunes 6 (windows box) and can't find out how to add a radio station to the library

  • Acpi_call not working. [did before]

    Hi I'm coming back from a short session using Ubuntu. Previously I've always used acpi_call (from AUR) to turn off my Nvida card to gain full battery life. It has served me well all the time but now I cant get it to work at all and since I'm used to

  • Why aren't my files in acrobat ordering themselves properly?

    If I have files named File1, File 2, File 3.........File10, File11, File12, when they upload to acrobat.com, they rearrange to File1, File10, File11, File12, File2, File 3....etc. Why don't they arrange themselves into a correct numbering order? It's

  • ClassCastException on SAX parser factory newInstance

    When trying to instantiate a parser factory, if none of the weblogic classes have been accessed, the instantiation goes well. If a weblogic class has been accessed, then I get the following stacktrace: java.lang.ClassCastException: weblogic.xml.jaxp.

  • Why does PrP not include AE-style proxy functions?

    Forgive me if it's a silly question, but I'm genuinely curious. After Effects gives the user the option to right-click any file in the Projects panel and choose Create Proxy, in any number of formats. It then automatically replaces that file with its