JTree and selected tree node
I am allowing the user to search for a node in a JTree. I can find the node and progamatically expand and select the node. What I would like to do next is find the x,y coordinates of this selected node so I can use Robot to move the mouse to this node. I have hover help which is chock full of information in HTML describing this node, however, the user now is required to move the cursor to this selected node to see the hover help.
Any help would be appreciated.
Hi ,
try this
jlabel.setIcon( null ) ;
Similar Messages
-
Assigning Selected Tree Node Value To An Item
Hi guys,
I want to assign selected tree node's value to a page item. This item can be a textbox or a label (display only). How can i do that? I tried to use "Selected Node Page Item" property which is available on Tree Attributes. But I couldn't assign the value without refreshing whole page.
Do you have any idea?
Thanks.Hi ,
Thank you that was exactly what I was looking for. I couldn't find how to pass database column to javascript as an input parameter. So thanks for your help. I made a couple of correction :
1) I put additional ' characters to ('''||"NAME"||''') this part because my field is varchar.
select case when connect_by_isleaf = 1 then 0
when level = 1 then 1
else -1
end as status,
level,
NAME as title,
null as icon,
"ID" as value,
null as tooltip,
'javascript:setFObjName('''||"NAME"||''')' As link
from "#OWNER#"."TABLE_NAME"
start with "PID" is null
connect by prior "ID" = "PID"
2) In script I have added ' character before and after page item.
function setFObjName(pobjName){
$s('P1_OBJ_NAME', pobjName);
So it works. Thanks tfor your help. -
Version: Jdeveloper 11.1.2.1.0
how to get programmatically tree node value.
i have tried but cann't read value from selected node.
please help me.
here is my application creation steps:
1. New Application
2. Fusion Web Application (ADF) Template
3. Create View Object VOTreeMst
Query:
Select Department_Name,Department_Id
From Departments
4. Create View Object VOTreeChd
Query:
Select Last_Name,Employee_Id,Department_Id
From Employees
5. Create View Link VLTreeMstChd
VOTreeMst.DepartmentId=VOTreeChd.DepartmentId
And Add to Application Module
6. Create page page1 in ViewController
New-->Web Tier-->JSF/Facelets-->Page
Selected Document Type JSP XML
7. Drag VOTreeMst1 From Data Controls into page1
and select Tree-->ADF Tree
8. ADD java Code into selection Listener
public void nodeSelect(SelectionEvent selectionEvent) {
//original selection listener set by ADF
String adfSelectionListener = "#{bindings.VOTreeMst1.treeModel.makeCurrent}";
//make sure the default selection listener functionality is preserved.
//you don't need to do this for multi select trees as the ADF binding
//only supports single current row selection
/* START PRESERVER DEFAULT ADF SELECT BEHAVIOR */
FacesContext fctx = FacesContext.getCurrentInstance();
Application application = fctx.getApplication();
ELContext elCtx = fctx.getELContext();
ExpressionFactory exprFactory = application.getExpressionFactory();
MethodExpression me = null;
me = exprFactory.createMethodExpression(elCtx, adfSelectionListener, Object.class,
new Class[] { SelectionEvent.class });
me.invoke(elCtx, new Object[] { selectionEvent });
/* END PRESERVER DEFAULT ADF SELECT BEHAVIOR */
RichTree tree = (RichTree)selectionEvent.getSource();
TreeModel model = (TreeModel)tree.getValue();
//get selected nodes
RowKeySet rowKeySet = selectionEvent.getAddedSet();
Iterator rksIterator = rowKeySet.iterator();
//for single select configurations, thi sonly is called once
while (rksIterator.hasNext()) {
List key = (List)rksIterator.next();
JUCtrlHierBinding treeBinding = null;
CollectionModel collectionModel = (CollectionModel)tree.getValue();
treeBinding = (JUCtrlHierBinding)collectionModel.getWrappedData();
JUCtrlHierNodeBinding nodeBinding = treeBinding.findNodeByKeyPath(key);
Row rw = nodeBinding.getRow();
//print first row attribute. Note that in a tree you have to determine the node
//type if you want to select node attributes by name and not index
String rowType = rw.getStructureDef().getDefName();
if(rowType.equalsIgnoreCase("VOTreeMst")){
System.out.println("This row is a department: " + rw.getAttribute("DepartmentId"));
else if(rowType.equalsIgnoreCase("VOTreeChd")){
System.out.println("This row is an employee: " + rw.getAttribute("EmployeeId"));
else{
System.out.println("Huh ????");
// ... do more usefuls stuff here
9. when i click on first node it is working but i click on second node it is not working
error message::
<LifecycleImpl> <_handleException> ADF_FACES-60098:Faces lifecycle receives unhandled exceptions in phase INVOKE_APPLICATION 5
javax.el.ELException: java.lang.NullPointerException
at com.sun.el.parser.AstValue.invoke(Unknown Source)
at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodExpression(UIXComponentBase.java:1589)
at org.apache.myfaces.trinidad.component.UIXTree.broadcast(UIXTree.java:237)
<RegistrationConfigurator> <handleError> ADF_FACES-60096:Server Exception during PPR, #1
javax.el.ELException: java.lang.NullPointerException
I have also tried using following code but same problem
public void onTreeSelect(SelectionEvent selectionEvent) {
//original selection listener set by ADF
String adfSelectionListener = "#{bindings.VOTreeMst1.treeModel.makeCurrent}";
//make sure the default selection listener functionality is preserved.
//you don't need to do this for multi select trees as the ADF binding
//only supports single current row selection
/* START PRESERVER DEFAULT ADF SELECT BEHAVIOR */
FacesContext fctx = FacesContext.getCurrentInstance();
Application application = fctx.getApplication();
ELContext elCtx = fctx.getELContext();
ExpressionFactory exprFactory = application.getExpressionFactory();
MethodExpression me = null;
me = exprFactory.createMethodExpression(elCtx, adfSelectionListener, Object.class,
new Class[] { SelectionEvent.class });
me.invoke(elCtx, new Object[] { selectionEvent });
/* END PRESERVER DEFAULT ADF SELECT BEHAVIOR */
RichTree tree = (RichTree)selectionEvent.getSource();
TreeModel model = (TreeModel)tree.getValue();
//get selected nodes
RowKeySet rowKeySet = selectionEvent.getAddedSet();
Iterator rksIterator = rowKeySet.iterator();
//for single select configurations, thi sonly is called once
while (rksIterator.hasNext()) {
List key = (List)rksIterator.next();
JUCtrlHierBinding treeBinding = null;
treeBinding = (JUCtrlHierBinding)((CollectionModel)tree.getValue()).getWrappedData();
JUCtrlHierNodeBinding nodeBinding = treeBinding.findNodeByKeyPath(key);
Row rw = nodeBinding.getRow();
//print first row attribute. Note that in a tree you have to determine the node
//type if you want to select node attributes by name and not index
System.out.println("row: " + rw.getAttribute(0));
But
If i create .jspx page From
Web Tier->Jsp->page Then it is working fine
when i create .jspx page From
Web Tier->JSF\Facelets->page Then it is not working
i need to get value from "Web Tier->JSF\Facelets->page"
is there any help please?You should try Franks generic selectionListener http://www.oracle.com/technetwork/developer-tools/adf/learnmore/25-generic-tree-selection-listener-169164.pdf. For help on hoe to get the selected tree node data check http://www.oracle.com/technetwork/developer-tools/adf/learnmore/26-get-selected-tree-node-data-169165.pdf
Timo -
Error in Getting Selected Tree node From POPUPMENU
Environment: Forms 9i, 9i AS
The Folowing code is written with in POPUP MENU to get the selected tree node. It always returns 0. The samE code works fine with in any other TRIGGER. Is it Forms BUG?
v_sel_tree := ftree.GET_TREE_SELECTION(v_item,1);Whether or not it is a bug you need a workaround.
How about getting the when-tree-node-selected to set a package variable and look at its value in the pop-up menu code. -
Af:tree - how do I highlight the selected tree node?
af:tree
I checked the generated CSS file. I found that when a tree node is selected, the related CSS attribute is:
.xj:link{
font-family:Arial,Helvetica,Geneva,sans-serif;
font-size:10pt;
font-weight:normal;
color:#663300
I created a customized CSS attribute, but then all of the links have the customized CSS attributes.
How do I just highlight the selected tree node link?
Thanks,
--Toddtry doing the onclick javascript method
you have to place it on the node element and id must be made dynamic
for this use 'this.id'
by which the current id of the node is passed
and by capturing the id name in a var
use the same for invoking its selected property and make it true
like this
var currentid = this.id;
this.form.currentid.selected = true; -
Value of currently selected tree node
Hi there,
I'm new to Apex(4.1.1) and i'm having a little problem.
I got 2 Pages. The frist one consists of a treeregion and a submit button.
The Second one is a Report.
I want to create a workflow, that the user selects a treenode and presses submit. Then he'll be redirected to the reportspage,
wich will show him a report depending on the treenode he selected on the first Page.
Problem:
I have no idea how i can read the value of the selected treenode.
I hope you can help me.
thanks,
FredericHi Frederic,
To obtain the value of the selected tree node, you can make use of the "Selected Page Node Item" attribute on the Tree Attributes page. Just create an item on your page, and set the "Selected Page Node Item" to that new page item. Then populate that item via the LINK parameter of your tree query. For an example, take a look at the following: http://apex.oracle.com/pls/apex/f?p=36648:6 , where I'm setting my page item P6_SELECTED_NODE to the value of the node selected on the first tree i.e. empno. Your report query would need to reference the "Selected Page Node Item", to ensure that it displays information related to the selected tree node.
I hope this helps.
Regards,
Hilary -
Highlight the selected Tree Node
Hello Everyone,
Can someone plz tell me how to highlight the selected tree node ?
After selection, user should be able to see which node was last selected.
ThanksHello,
for me it is not really clear what you have done. Sorry!
Because I have problems to paste code, I will describe how you can test that function.
Take the BSP application HTMLB_SAMPLES and copy it to ZHTMLB_SAMPLES. Take page "treeviewSample.htm" and add the following node behind node22:
<htmlb:treeNode id = "node23"
text = "Node 2.2, normal text"
selection="PRIMARYSELECTION">
Perhaps this will show you how it works and help you.
As far as I can see the attribute "selection" can't be set via table.
Best regads
Renald
Edited by: Renald Wittwer on Jan 21, 2010 1:36 PM -
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 -
Need Help -- How to Change the icon of a selected Tree Node
Hi java gurus,
i am working on Jtree application, and i am adding image icons to the Nodes.
my dought is when i select a node, i want to display that selected node as opened and all other icons should remain closed.
Example:
-- root
|
----child
----child1
----child2
|
----SubChild
----SubChild1
----subchild2
Here if i am selecting Child2 means, only the image icon of that child2 should open the nodes and display the icon , all other icons from root to subchild should remain same as closed.
please some one suggest how i can do it,
Thanks in advance,
Cheers,
MuraliStop crossposting!
http://forum.java.sun.com/thread.jspa?threadID=787916&messageID=4476842#4476842 -
Jtree: "check if tree node is a folder" not wrkin
Hi, I have a JTree and If a folder does not has any file, it displays as file not folder. Is there any way to fix it. I want to represent an empty folder as folder not file. here is the code. Thanks for help.
if(!f.isDirectory()) {
System.out.println("FILE - " + f.getName());
DefaultMutableTreeNode child = new DefaultMutableTreeNode(f.getName());
node.add(child);
else {
DefaultMutableTreeNode child = new DefaultMutableTreeNode(f.getName());
node.add(child);
File fList[] = f.listFiles();
for(int i = 0; i < fList.length; i++)
getList(child, fList);Sorry for not formatting the code:
here is the code again:
public void getDirectories()
getList(root, new File("c:/FIST/Projects/"));
KeyStroke ks = KeyStroke.getKeyStroke("ctrl A");
tree.getInputMap().put(ks, "none");
public void getList(DefaultMutableTreeNode node, File f)
if(!f.isDirectory())
DefaultMutableTreeNode child = new DefaultMutableTreeNode(f.getName());
int i=child.getLevel();
if(i==0)
node.add(child);
else {
DefaultMutableTreeNode child = new DefaultMutableTreeNode(f.getName());
node.add(child);
File fList[] = f.listFiles();
for(int i = 0; i < fList.length; i++)
getList(child, fList); -
Select tree node in tree component
hi,
i am developing a web site which has a site map as a tree component, the sitemap is a inserted in a page fragment, users could click tree nodes to go to corresponding pages. also on other pages, i have next and previous buttons which allow users to navigate through pages. the question is how can i update the tree component when users navigate using the next and previous buttons so that the correct tree node is highlighted?
i tried to use the selected property for the tree component, but it does not do anything.
thanks,
leeHi,
Duplicate thread of
http://swforum.sun.com/jive/thread.jspa?threadID=64518
MJ -
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; -
JTree and JButton in node.
Helo.
I've a question regarding JTree component. I was wondering if it is possible at all.
I want to build JTree component with JButton(JPanel) in each node, for example:
RootNode
|
---String [JButton][JButton]
|
---String [JButton][JButton]
Is there possibility to put JPanel into children node.
Maybe anyone did do this before?
Thanks in advance for any help.
RegardsThis is possible. You'll have to take a look at TreeCellRenderer and TreeCellEditor, and maybe the tutorial at http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html . Basically, both interfaces allow you to return arbitrary components for rendering / editing tree nodes. The default implementation is based on JLabels, but you can use complex panels with multiple child components as well.
-
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? -
Retieve the related childern to the selected Tree Node
Hello all,
From here i got the folowing code,it helps me to retrieve the whole record which is related to the selected node in
WHEN-TREE-NODE-SELECTED Trigger :
declare
rank number := 0;
begin
rank :=
ftree.get_tree_node_property('TREE_BLOCK_TEST.TREE13',
:system.trigger_node, ftree.node_depth);
if rank >= 1 then
GO_BLOCK ('INSP_EQUIPMENT_TYPE');
set_block_property ('INSP_EQUIPMENT_TYPE', default_where,
'EQUIPMENT_TYPE_D='||ftree.get_tree_node_property('TREE_BLOCK_TEST.TREE13',
:system.trigger_node, ftree.node_value));
Execute_Query(No_ValiDATE);
end if;
end; What i want to do is to retieve not only the current record for the selected node but aslo the related childern in the tree to this node.
Could anyboady help me pls. ?!
Regards,
Abdetu..Hi Tony,
what i am trying to do is to display all childern related to the parent 's node selected from the tree that's works fine..
But i want to display the related datablock selected to the child itself the following can't do that can u help me doing it pls...!
DECLARE
rank number := 0;
HTREE$ ITEM := Find_Item('TREE_BLOCK_TEST.TREE13');
BEGIN
IF :SYSTEM.TRIGGER_NODE_SELECTED = 'TRUE' THEN
rank := ftree.get_tree_node_property
('TREE_BLOCK_TEST.TREE13',:system.trigger_node, ftree.node_depth);
if rank = 1 then
set_block_property ('INSP_EQUIPMENT_TYPE', default_where
, 'parent_id='||ftree.get_tree_node_property('TREE_BLOCK_TEST.TREE13',
:system.trigger_node, ftree.node_value));
GO_BLOCK ('INSP_EQUIPMENT_TYPE');
Execute_Query(No_ValiDATE);
elsif rank > 1 then
set_block_property ('INSP_EQUIPMENT_TYPE', default_where
,'EQUIPMENT_TYPE_D='||ftree.get_tree_node_property('TREE_BLOCK_TEST.TREE13',
:system.trigger_node, ftree.node_value));
else
:INSP_EQUIPMENT_TYPE.EQUIPMENT_TYPE :=
FTREE.GET_TREE_NODE_PROPERTY(HTREE$, :SYSTEM.TRIGGER_NODE, FTREE.NODE_LABEL);
END IF;
END IF;
END;
Maybe you are looking for
-
'System Error' status at Message Monitoring( HTTP to FILE )
I have created a scenario HTTP to FTP. I sent message to XI server using the HTTP Client. After sending the message I am getting the response at browser. Result: http-Status: 200 Message accepted Payload: But when I look in to the Message monitoring
-
I am facing a strange SQL exception:- The code flow is like this: .Net 4.0 --> Entity Framework --> SQL 2008 ( StoredProc --> Function {Exception}) In the SQL Table-Valued Function, I am selecting a column (nvarchar(50)) from an existing table and (a
-
hi The system automatically created a free goods sub- item for the order with purchase order number ##LO605-ZA##14. The system runs pricing for this sub-item even though it is free of charge. Later i will give discount r100.but i need to know the set
-
Display Siebel Pop up box with Service Request count for every 1 hr
Hi For our client business, we need to achieve the below functionality. Please suggest me the best method to implement. 1. When the user logged into the application, it should pop up a box by displaying the No# of SR in "New" Status that are assigned
-
Communication between a GUI and a Server
Hi, I have created a main JFrame which in turn initializes a Server object. The Server (multithreaded) accepts socket connections. Is there any way for the Server to report back at the GUI that a connection request was received (so as to print a mess