Package javax.swing

Examples of javax.swing.JTree$AccessibleJTree$AccessibleJTreeNode


    private static JTree tree() {
      DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
      DefaultMutableTreeNode node = new DefaultMutableTreeNode("node");
      root.add(node);
      JTree tree = new JTree(root);
      tree.collapseRow(0);
      tree.setName("tree");
      tree.addMouseListener(new MyMouseListener(popupMenu()));
      return tree;
    }
View Full Code Here


    }

    private MyWindow() {
      super(JTreeToggleExpandStateTask_toggleExpandState_Test.class);
      treeRoot = createRoot();
      tree = new JTree(treeRoot);
      tree.setPreferredSize(new Dimension(200, 100));
      addComponents(tree);
      tree.collapsePath(new TreePath(treeRoot));
    }
View Full Code Here

    final DefaultMutableTreeNode root;

    private MyWindow() {
      super(BasicJTreeCellReader_valueAt_Test.class);
      root = newRoot();
      tree = new JTree(root);
      addComponents(tree);
    }
View Full Code Here

    final TreeNode treeRoot;

    private MyWindow(int treeRootChildCount) {
      super(JTreeChildOfPathCountQuery_childCount_Test.class);
      treeRoot = root(treeRootChildCount);
      tree = new JTree(treeRoot);
      addComponents(tree);
    }
View Full Code Here

    private MyWindow() {
      super(JTreeExpandPathTask_expandTreePath_Test.class);
      root = new DefaultMutableTreeNode("root");
      node = new DefaultMutableTreeNode("node");
      node.add(new DefaultMutableTreeNode("node1"));
      tree = new JTree(root);
      root.add(node);
      tree.setPreferredSize(new Dimension(300, 200));
      addComponents(tree);
      tree.collapsePath(new TreePath(root));
    }
View Full Code Here

     * @throws RenderingException if there's rendering problem
     */
    public void renderNode(BridgePeer peer, BridgeRenderContext context,
            Object output, TreePath path, String treePath) throws RenderingException
    {
        JTree tree = (JTree) peer.getComponentObject();
        TreeModel model = tree.getModel();  
        Component com = null;
        Object value = path.getLastPathComponent();
               
        boolean enableFlag = true;
        boolean edit = tree.isEditable();
        if (edit)
        {
            com = (Component)tree.getCellEditor().getTreeCellEditorComponent(tree, value, true, true, model.isLeaf(value), 0);           
        } else
        {
            com = (Component)tree.getCellRenderer().getTreeCellRendererComponent(tree, value, true, true, model.isLeaf(value), 0, true);           
        }
        BridgePeer childPeer = context.getContext().getPeer(com);
        if (childPeer == null)
        {
            tree.add(com);
            com.addNotify();
            childPeer = context.getContext().getPeer(com);
        }
        //setting the size?
       
View Full Code Here

     * The offset is then set on the TreeTableTextField component created in
     * the constructor, and returned.
     */
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int r, int c) {
      Component component = super.getTableCellEditorComponent(table, value, isSelected, r, c);
      JTree t = getTree();
      boolean rv = t.isRootVisible();
      int offsetRow = rv ? r : r - 1;
      Rectangle bounds = t.getRowBounds(offsetRow);
      int offset = bounds.x;
      TreeCellRenderer tcr = t.getCellRenderer();
      if (tcr instanceof DefaultTreeCellRenderer) {
        Object node = t.getPathForRow(offsetRow).getLastPathComponent();
        Icon icon;
        if (t.getModel().isLeaf(node))
          icon = ((DefaultTreeCellRenderer) tcr).getLeafIcon();
        else if (tree.isExpanded(offsetRow))
          icon = ((DefaultTreeCellRenderer) tcr).getOpenIcon();
        else
          icon = ((DefaultTreeCellRenderer) tcr).getClosedIcon();
View Full Code Here

   
    CheckNode root = new CheckNode("");
    root.add(students);
    root.add(tests);

    tree = new JTree( root );
    tree.setRootVisible(false);
    tree.setCellRenderer(new CheckRenderer());
    tree.getSelectionModel().setSelectionMode(
      TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION
    );
View Full Code Here

   
    // change this
    root.add(tests);
    tests.add(t);

    tree = new JTree( root );
    tree.setRootVisible(false);
    tree.setCellRenderer(new CheckRenderer());
    tree.getSelectionModel().setSelectionMode(
      TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION
    );
View Full Code Here

     */
    public void processInput(BridgeComponentPeer peer, BridgeInputContext context, Map inputForm) throws InputException
    {
        if (hasEvent(peer, inputForm)) //quick check for table visibility
        {
            JTree tree = (JTree) peer.getComponentObject();
            TreeModel model = tree.getModel();
            String pathString = (String) inputForm.get(peer.getId());
            String actionKey = peer.getId() + "-action";
            String action = (String) inputForm.get(actionKey);
            if (!StringUtils.isNullOrEmpty(action))
            {
                if (action.equals("selected"))
                {
                    TreePath path = getTreePath(model, pathString);
                    TreeEvent evt = new TreeEvent(tree, path)
                    {

                        public void dispatch()
                        {
                            ((JTree) getSource()).setSelectionPath(getPath());
                        }
                    };
                    postEvent(context, evt);
                } else if (action.equals("selected-doubleclicked"))
                {
                    TreePath path = getTreePath(model, pathString);
                   
                    TreeEvent evt = new TreeEvent(tree, path)
                    {
                        public void dispatch()
                        {
                            JTree tree = (JTree)getSource();
                            TreePath path = getPath();
                            tree.setSelectionPath(path);
                            if (tree.isExpanded(path)){
                                tree.collapsePath(path);
                            } else {
                                tree.expandPath(path);
                            }                       
                            MouseListener[] listeners = tree.getMouseListeners();
                            Rectangle rec = tree.getPathBounds(path);
                            for (int i=0; i<listeners.length; i++){
                                listeners[i].mousePressed(
                                        new MouseEvent(tree, MouseEvent.MOUSE_CLICKED, System.currentTimeMillis(), 0, (int)rec.getX(), (int)rec.getY(), 2, false)
                                );
                            }
                        }
                    };
                    postEvent(context, evt);
                } else if (action.equals("addSelected"))
                {
                    TreeSelectionModel smodel = tree.getSelectionModel();
                    TreePath path = getTreePath(model, pathString);
                    if (smodel.isPathSelected(path))
                    {
                        TreeEvent evt = new TreeEvent(tree, path)
                        {

                            public void dispatch()
                            {
                                ((JTree) getSource()).removeSelectionPath(getPath());
                            }
                        };
                        postEvent(context, evt);
                    } else
                    {
                        TreeEvent evt = new TreeEvent(tree, path)
                        {

                            public void dispatch()
                            {
                                ((JTree) getSource()).removeSelectionPath(getPath());
                            }
                        };
                        postEvent(context, evt);
                    }
                    tree.setSelectionPath(path);
                } else if (action.equals("expanded"))
                {
                    TreePath path = getTreePath(model, pathString);
                    TreeEvent evt = new TreeEvent(tree, path)
                    {
View Full Code Here

TOP

Related Classes of javax.swing.JTree$AccessibleJTree$AccessibleJTreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.