Expand tree node by clicking onto the node label
I have followed this example to expand the nodes with a clic on the tree :
[http://www.oracle.com/technetwork/developer-tools/adf/learnmore/20-expand-tree-node-from-label-169156.pdf]
My code:
JSPX:
<af:resource type="javascript" source="js/glasspane.js"/>
<af:tree value="#{bindings.OpcionesPadreView1.treeModel}" var="node"
rowSelection="single" id="t1" partialTriggers=":::cbNuevCpta"
binding="#{pageFlowScope.GestionDocumentos.t1}"
selectionListener="#{bindings.OpcionesPadreView1.treeModel.makeCurrent}">
<f:facet name="nodeStamp">
<af:commandImageLink text="#{node.Gesdopcach}" id="ot1"
action="#{bindings.LoadDir.execute}"
actionListener="#{bindings.LoadFile.execute}"
icon="/images/GestionDocumentos/folder20x20.png"
partialSubmit="true">
</af:commandImageLink>
</f:facet>
<af:clientListener method="expandTree" type="selection"/>
</af:tree>
Js:
function expandTree(evt) {
alert('In');
var tree = event.getSource();
rwKeySet = event.getAddedSet();
var firstRowKey;
for (rowKey in rwKeySet) {
firstRowKey = rowKey;
if (tree.isPathExpanded(firstRowKey)) {
tree.setDisclosedRowKey(firstRowKey, false);
}else {
tree.setDisclosedRowKey(firstRowKey, true);
When i clic on the labels the tree doesn't expand, the alert also is not shown. The problem could be the <af:resource>, but i have this tag in all my pages and all javascripts work. I also changed the commandLink with an outputText, but doesn't work.
Edited by: Miguel Angel on 21/06/2012 12:53 PM
At least the call the javascript works, but this line doesn't work, anybody know why?:
rwKeySet = evt.getAddedSet();
Similar Messages
-
Hi there,
I used the following manual (http://manuals.info.apple.com/MANUALS/1000/MA1583/en_US/boot_camp_install-setup_ 10.7.pdf) in attempt to install windows 7 onto my mac but I get an error at Step 3 - windows installation process
I selected the BOOTCAMP partitioned drive as mentioned, clicked the advance options, and then reformatted that drive. What happens next is the drive changes name from BOOTCAMP to 'untitled'. I then tried to click 'next' button but it won't let me proceed any further and didn't state clearly why it couldn't go through (instead says to check the log file for reason why - but then I have not clue where this log file is located in as well!).
I had a look at that partitioned drive after to find that it is NTFS format (when I went back to OS x) so it appears that I am doing the right thing so that shouldn't be the issue..
Does anyone know what could be wrong? or what I should try to do next?
Could it be a format error because when i click onto the 'untitled' drive, there is nothing in there.Hi Steve1904,
So you have use the backup and Restore to restore your files from Windows XP to Windows 7 directly?
This should be considered not work.
If you would like to transfer files between Windows XP and Windows 7, you need another tool called Windows Easy Transfer.
See the article below if you would like to upgrade from Windows XP to Windows 7:
Upgrading from Windows XP to Windows 7
If possible, follow the steps there, then things should be OK.
Best regards
Michael Shao
TechNet Community Support -
Itunes will not open. I click onto the icon and it does nothing. I've uninstalled it twice and still nothing. Rebooted and nothing. I plug my iphone as well as my ipod and still nothing happens. Help please.
I, too, am having a serious problem with my iTunes.
It shows that iTunes is taking up usage on my computer but there is no error message when I try to open it. Nothing even happens. iTunes does not come up and I am searching for a possible answer.
We recently had a power outage but we got power back Sunday and when we did iTunes stopped working. Before this incident iTunes usually worked and when it didn't a simple re-start was used to fix it. However now I have tried that several times and it is not working.
Help? -
When I click onto the firefox webbrowser, I get the message "firefox has stopped working, windows will close the application to find a solution to the problem."
I had this exact same problem. I found this fix and it worked for me.
Step 1:
Browse to C:\Program Files (x86)\Common Files\Apple\Apple Application Support and copy the filen named QTMovieWin.dll.
Step 2:
Browse and past that file into C:\Program Files (x86)\iTunes.
Hope this helps you. I wish I could remember where I saw this originally so I could thank them.
Good Luck.
Anthony -
Expanding an af:tree node by clicking onto its label
Dear all,
I am ussing af:tree same as in this link.
http://www.oracle.com/technology/products/jdev/tips/fnimphius/js_disclose_tree_path.html
But may af:tree still can't expend clicking on node label.
I am using jdeve11.1.1.2.0, here is my code.
<af:resource type="javascript" >
function expandNode(event){
var _tree = event.getSource();
rwKeySet = event.getAddedSet();
var firstRowKey;
for(rowKey in rwKeySet){
firstRowKey = rowKey;
// we are interested in the first hit, so break out here
break;
if (_tree.isPathExpanded(firstRowKey)){
_tree.setDisclosedRowKey(firstRowKey,false);
else{
_tree.setDisclosedRowKey(firstRowKey,true);
</af:resource>
<af:tree id="sTree" value="#{MenuGenerator.treeModel}" var="node"
expandAllEnabled="false" styleClass="stree" >
<f:facet name="nodeStamp">
<af:outputText value="#{node.name}" />
</f:facet>
<af:clientListener method="expandNode" type="selection"/>
</af:tree>
With Regards,
WPhi Frank,
i get it too. but behaviour is different as i thought.
lets say i click on one of the node to expand it.
then i click on it again to collapse.
but i can't do it like this because my focus is still on that node.
i mean when i click on one node to expand/collapse then i click on it again to expand/collapse.
is it possible? and how to achieve this?
With Regards,
WP -
Double click on the node,ALV tree, subscreen
Hi,
I have a small requirement in ALV Tree
left side i get a tree and when i double click on one of it , i'm trying to display the subscreen. even though i am setting the paramaters to the screen but i'm unable to get those values in the subscreen.
example
Name Description subscreen 0101
xyz xyz desc (double click on this) name = XYZ
ABC abs desc descrip = xyz desc
This is what the requirement is:
Please help me out with the solution.
BhavanaHi Bhavana,
Register your double click event in the ALV Tree program. Then call the respective subscreen using sy-ucomm value.
IF NOT r_ucomm IS INITIAL.
CASE r_ucomm.
WHEN '&F03'.
SET SCREEN 100.
LEAVE SCREEN.
endif.
Refer the below code for setting the registering the event.
CALL METHOD tree->get_registered_events
IMPORTING
events = l_events_s.
l_event-eventid = cl_gui_column_tree=>eventid_item_double_click.
APPEND l_event TO l_events_s.
CALL METHOD tree->set_registered_events
EXPORTING
events = l_events_s
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
CREATE OBJECT l_events_receiver.
SET HANDLER l_events_receiver->handle_item_click FOR tree.
CLASS lcl_events_receiver DEFINITION. "#EC *
PUBLIC SECTION.
METHODS:
handle_item_click FOR EVENT item_double_click OF cl_gui_alv_tree
IMPORTING node_key fieldname.
ENDCLASS. "lcl_handle_events DEFINITION
CLASS lcl_events_receiver IMPLEMENTATION.
METHOD handle_item_click.
PERFORM employee_data USING node_key fieldname.
CALL SCREEN 300.
ENDMETHOD. "HANDLE_ITEM_DOUBLE_CLICK
ENDCLASS. "lcl_events_receiver IMPLEMENTATION
Thanks.
Ganesh R K
Edited by: Ganesh.rk83 on Jun 23, 2011 11:21 AM -
The Jtree is not refreshing with new values when mouse click on the node
hi ,
I am creating a tree from a vector .The values in the vector is coming from the JTable data after satisfing the some condition. But the data in the Jtable is changing time to time so the data in the vector is also changing .
But the problem is that when first I create a tree with that data the tree is created but for the next time I click on the tree node the tree is not changing i.e. it is not created with the new values that is stored in the vector at that time .what to do .Please help
I am using DefaultMutableTreeNode for creating the tree .In starting I have created one root and the one it's child .Now the next subtree of the root child have to be created by this vector data. this subtree should be updated according to the values in the vecter.
public void valueChanged(TreeSelectionEvent e) {
//code here
subtreecreat();
//some function that create tree after cheching the some condition here
subtreecreat() {
Enumeration en=vector.elements();
while(en.hasMoreElements())
DefaultMutableTreeNode servername = new DefaultMutableTreeNode(en.nextElement());
node.add(servername);
Please help it is very urgent
Thanks in Advance,
anumWell, you can either use a custom TreeModel that tracks your Vector, or you can use a DefaultTreeModel and call model.reload(node) to refresh the tree below the specified node.
-
Building tree when we know all the nodes and levels
Hi Experts,
What is the best way to implement tree in web dynpro for abap when we know all the nodes, there levels and parents.
I have the structure like this:
id text level parent
1 root 1 1
1.1 ; node1.1 ; 2 1
1.1.1 ; node 1.1.1 ; 3 1.1
1.2 ; node1.2 ; 2 1
it could be up to 10 levels with hundreds of nodes
Thanks,
Anthonyhi
Refer this online help:
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/21/ad884118aa1709e10000000a155106/content.htm
check the WDA : WDR_TEST_TREE,WDT_TREE,WDT_TREE_TABLE_BY_KEY,WDT_TREE_TABLE_BY_NST.
refer this wiki :
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/profile/2007/09/11/integrationofTreeStructureinaTableusingWebdynpro+Abap&
refer this thread :
creating tree
regards,
amit -
In the middle of using wi-fi on my MacBook Pro, I lost contact. No other apple devices (iMac, iPhone or iPad) are affected. When I click on the empty wi-fi icon (top right of the screen) it gives the message: Wi-Fi: No hardware installed. has anyone any clues?
Wi-Fi: No hardware installed. has anyone any clues?
Unfortunately, this message is almost always an indication that the internal AirPort card on the Mac has failed and will need to be replaced. This is a job for repair shop.
If you have a recent Mac, a Hardware Test may reveal this as well:
http://support.apple.com/kb/HT1509 -
I am using a new laptop and wish to make a purchase, quite correctly have been prompted to answer ID Security question but it is impossible to click on the page location to provide the answer...it's getting hard to spend my money with I tunes...help!
Also my computer wont let me get on icloud.
-
Why does the current player need me to keep clicking onto the next podcast?
This is just not a good player.
That one is usually the culprit. As long as it's running, it gives a "false positive" for Safari.
Download the offline installer: Flash Player 12 (Mac OS X)
Reboot and run it before opening anything else. -
How to expand all the nodes in a tree while loading the tree initially
Hi All
Now i am able to display the tree strucute in webdynpro.
but it is displaying the tree initially in collapsed mode until/unless we click on the node root it will be expanded.
but my requirement is i wanted to display the tree in expanded mode by default at runtime initially.
can you please provide any setting to be done or any sample code on the same then it would be great help to me.??
Thanks
TrishaHi,
isLeaf is an attribute you need to create under "CatalogEntries" node. And "isRoot" is not requried.
Download the sample project "TutWD_TreeByNestingTableColumn". See the below link to dnld this project.
https://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/503f22f6-b978-2a10-bf97-ddc21267e752 [original link is broken]
Do the changes in sample project as below:
Invoke this method in the init method as below (as it is in the same project).
addCatalogEntries(wdContext.nodeCatalogEntries(), "ROOT");
Change the code in addCatalogEntries() method as below.
Here we are calling the addCatalogEntries() method recursively for all the parent elements and we are changing the setExpanded property to true.
public void addCatalogEntries( com.sap.tut.wd.treetable.wdp.IPrivateTreeTableView.ICatalogEntriesNode node, java.lang.String parentId )
//@@begin addCatalogEntries()
IPrivateTreeTableView.ICatalogEntriesElement newCatalogEntriesElement;
for (int i = 0; i < Catalog.getLength(); i++) {
if (parentId.equals(Catalog.getParentId(i))) {
// create new context node element
newCatalogEntriesElement = node.createCatalogEntriesElement();
node.addElement(newCatalogEntriesElement);
// provide node elements with data
newCatalogEntriesElement.setID(Catalog.getCATALOGID(i));
newCatalogEntriesElement.setTITLE(Catalog.getTITLE(i));
newCatalogEntriesElement.setDESCRIPTION(Catalog.getDESCRIPTION(i));
newCatalogEntriesElement.setAMOUNT(Catalog.getAMOUNT(i));
if ("ARTICLE".equals(Catalog.getCATALOGTYPE(i))) {
// checkbox is visible by default
newCatalogEntriesElement.setPUBLISHED(Catalog.getPUBLISHED(i));
// third level is last level
newCatalogEntriesElement.setIsLeaf(true);
} else {
// a CATEGORY does not use the checkbox column
newCatalogEntriesElement.setUsageOfPublishedAttribute(WDVisibility.BLANK);
newCatalogEntriesElement.setIsLeaf(false);
newCatalogEntriesElement.setChildrenLoaded(true);
newCatalogEntriesElement.setExpanded(true);
addCatalogEntries(newCatalogEntriesElement.nodeChildCatalogEntries(),newCatalogEntriesElement.getID()); -
Click on the searched hierachical tree node
Hi,
when i search the hierarchical tree for a string then all the matching nodes come selected.Then when i click on any of the search result nodes it does not work and otherwise i have to click on a non selected node and then click on the desired node .
For example i have created a tree for material used for manufacturing purpose.i want to display the related suppliers names in an adjacent grid by clicking on the node in the tree. how can i do that directly after getting the search node.??Bibekananda wrote:
Hi,
when i search the hierarchical tree for a string then all the matching nodes come selected.Then when i click on any of the search result nodes it does not work and otherwise i have to click on a non selected node and then click on the desired node .
For example i have created a tree for material used for manufacturing purpose.i want to display the related suppliers names in an adjacent grid by clicking on the node in the tree. how can i do that directly after getting the search node.??hi
i hope i get you
i think you have a form contain a block for tree and another block build on a database table and you want to execute query on the block when you select a node
and you have a search item to seach for a node and want to go to the block record when you clock on search without go to the node and select
try this in search button or when-validate-item of the search key
-- create a pkg specifiaction called tree_pkg and define the follwing variable
--node ftree.node;
PROCEDURE select_node IS
node ftree.node;
htree item;
node_label varchar2(3000);
node_val varchar2(3000);
state varchar2(3000);
begin
htree := find_item('BLOCK.TREE_ITEM');
node := Ftree.Find_Tree_Node(htree, '');
ftree.set_tree_selection(htree,node,ftree.select_on) ;
WHILE NOT Ftree.ID_NULL(node) LOOP
state := Ftree.Get_Tree_Node_Property(htree, node, Ftree.NODE_STATE);
node_label := Ftree.Get_Tree_Node_Property(htree, node, Ftree.NODE_label);
node_val := Ftree.Get_Tree_Node_Property(htree, node, Ftree.NODE_value);
if upper(node_label) like <your search item> then
ftree.set_tree_selection(htree,node,ftree.select_on) ;
tree_pkg.node := node;
exit;
end if;
node := Ftree.Find_Tree_Node(htree, '', ftree.find_NEXT,Ftree.NODE_LABEL,'', node);
END LOOP;
---- now you have the node number that result from search
node_val := Ftree.Get_Tree_Node_Property(htree, tree_pkg.node, Ftree.NODE_value);
-- then use this value in execute query on the supplier block
END;
try and respond -
How to dislay a frame when i clck on the node or leaf on the JTree
Hi All,
Iam doing project on swing. In that iam doing with JTree. The Jtree is displaying on the left side of the splitpane .My problem is if i click on the nodes or leaf in the JTree one panel should be open in on the right side of the spltpane. Iam pasting the code.please can any body knows the solution please send me.
regards
sonali
import java.awt.*;
import javax.swing.*;
import javax.swing.BorderFactory;
import javax.swing.border.*;
import java.awt.event.*;
import javax.swing.tree.*;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.event.TreeSelectionListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.tree.TreeSelectionModel;
import javax.swing.tree.DefaultTreeCellRenderer;
import java.net.URL;
import javax.swing.*;
import java.io.IOException;
import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JFrame;
import Test.Test1;
public class JFrame1 extends javax.swing.JFrame {
JScrollPane sp;
JPanel topPanel;
JPanel leftPanel;
JPanel bottomPanel;
JPanel rightPanel;
Border b ;
JTree tree;
DefaultTreeModel treeModel;
public JFrame1(){
getContentPane().setLayout(null);
setSize(405,305);
setVisible(false);
JPanel1.setLayout(null);
getContentPane().add(JPanel1);
JPanel1.setLayout(new GridLayout(1, 1));
JPanel1.setBounds(0,0,405,305);
JPanel1.add(JSplitPane1);
JSplitPane1.setBounds(0,5,405,305);
JSplitPane1.setContinuousLayout(false);
topPanel = new JPanel();
leftPanel = new JPanel();
bottomPanel = new JPanel();
topPanel.setLayout(new FlowLayout());
leftPanel.setLayout(null);
b = new EtchedBorder();
leftPanel.setBorder(b);
leftPanel.setBounds(0,0,300,305);
bottomPanel.setLayout(new FlowLayout());
rightPanel = new JPanel();
rightPanel.setBounds(108, 0, 300, 305);
JSplitPane1.setRightComponent(rightPanel);
JSplitPane1.setLeftComponent(leftPanel);
rightPanel.setLayout(null);
topPanel.setBounds(0,0,305,25);
b = new EtchedBorder(0);
topPanel.setBorder(b);
bottomPanel.setBounds(0,26,300,280);
b = new BevelBorder(1, Color.black,Color.black);
bottomPanel.setBorder(b);
rightPanel.add(topPanel);
rightPanel.add(bottomPanel);
JSplitPane1.setDividerLocation(120);
DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
DefaultMutableTreeNode subroot = new DefaultMutableTreeNode("SubRoot");
DefaultMutableTreeNode leaf1 = new DefaultMutableTreeNode("Leaf 1");
DefaultMutableTreeNode leaf2 = new DefaultMutableTreeNode("Leaf 2");
DefaultMutableTreeNode leaf3 = new DefaultMutableTreeNode("Leaf 3");
DefaultMutableTreeNode subroot1 = new DefaultMutableTreeNode("SubRoot1");
DefaultMutableTreeNode leaf11 = new DefaultMutableTreeNode("Leaf 11");
DefaultMutableTreeNode leaf21 = new DefaultMutableTreeNode("Leaf 21");
DefaultMutableTreeNode leaf31 = new DefaultMutableTreeNode("Leaf 31 skfjdsf sfjfdsl fslfkjdsfl sflkjaflksdfdslfjds lfsdlkfjdslk sdsdlkfjdsla fflkdasjfdslkjal");
DefaultMutableTreeNode subroot2 = new DefaultMutableTreeNode("SubRoot2");
DefaultMutableTreeNode leaf12 = new DefaultMutableTreeNode("Leaf 12");
DefaultMutableTreeNode leaf22 = new DefaultMutableTreeNode("Leaf 22");
DefaultMutableTreeNode leaf32 = new DefaultMutableTreeNode("Leaf 32");
treeModel = new DefaultTreeModel(root);
tree = new JTree(treeModel);
treeModel.insertNodeInto(subroot, root, 0);
treeModel.insertNodeInto(leaf1, subroot, 0);
treeModel.insertNodeInto(leaf2, root, 1);
treeModel.insertNodeInto(leaf3, root, 2);
treeModel.insertNodeInto(subroot1, root, 3);
treeModel.insertNodeInto(leaf11, subroot1, 0);
treeModel.insertNodeInto(leaf21, subroot1, 1);
treeModel.insertNodeInto(leaf31, subroot1, 2);
treeModel.insertNodeInto(subroot2, root, 3);
treeModel.insertNodeInto(leaf12, subroot2, 0);
treeModel.insertNodeInto(leaf22, subroot2, 1);
treeModel.insertNodeInto(leaf32, subroot2, 2);
sp = new JScrollPane();
sp.setBounds(0,0,300,305);
sp.getViewport().add(tree);
sp.setViewportBorder(BorderFactory.createRaisedBevelBorder());
leftPanel.add(sp,BorderLayout.CENTER);
// SymPropertyChange lSymPropertyChange = new SymPropertyChange();
// JSplitPane1.addPropertyChangeListener(lSymPropertyChange);
SymWindow aSymWindow = new SymWindow();
this.addWindowListener(aSymWindow);
SymComponent aSymComponent = new SymComponent();
this.addComponentListener(aSymComponent);
public JFrame1(String sTitle)
this();
setTitle(sTitle);
public void setVisible(boolean b)
if (b)
setLocation(50, 50);
super.setVisible(b);
static public void main(String args[])
(new JFrame1()).setVisible(true);
public void addNotify()
Dimension size = getSize();
super.addNotify();
if (frameSizeAdjusted)
return;
frameSizeAdjusted = false;
Insets insets = getInsets();
javax.swing.JMenuBar menuBar = getRootPane().getJMenuBar();
int menuBarHeight = 0;
if (menuBar != null)
menuBarHeight = menuBar.getPreferredSize().height;
setSize(insets.left + insets.right + size.width, insets.top + insets.bottom + size.height + menuBarHeight);
boolean frameSizeAdjusted = false;
javax.swing.JPanel JPanel1 = new javax.swing.JPanel();
javax.swing.JSplitPane JSplitPane1 = new javax.swing.JSplitPane();
/*class SymPropertyChange implements java.beans.PropertyChangeListener{
public void propertyChange(java.beans.PropertyChangeEvent event){
Object object = event.getSource();
if (object == JSplitPane1)
JSplitPane1_propertyChange(event);
/* void JSplitPane1_propertyChange(java.beans.PropertyChangeEvent event){
System.out.println("!");
sp.setSize((int)JSplitPane1.getLeftComponent().getBounds().getWidth()-2,(int)JSplitPane1.getLeftComponent().getBounds().getHeight()-2 );
sp.repaint();
tree.repaint();
class SymWindow extends java.awt.event.WindowAdapter{
public void windowActivated(java.awt.event.WindowEvent event){
Object object = event.getSource();
if (object == JFrame1.this)
JFrame1_windowActivated(event);
public void windowIconified(java.awt.event.WindowEvent event){
Object object = event.getSource();
if (object == JFrame1.this)
JFrame1_windowIconified(event);
void JFrame1_windowIconified(java.awt.event.WindowEvent event){
void JFrame1_windowActivated(java.awt.event.WindowEvent event){
class SymComponent extends java.awt.event.ComponentAdapter{
public void componentShown(java.awt.event.ComponentEvent event){
Object object = event.getSource();
if (object == JFrame1.this)
JFrame1_componentShown(event);
public void componentResized(java.awt.event.ComponentEvent event){
Object object = event.getSource();
if (object == JFrame1.this)
JFrame1_componentResized(event);
void JFrame1_componentResized(java.awt.event.ComponentEvent event){
System.out.println("!!");
JPanel1.setSize(this.getContentPane().getMaximumSize());
JSplitPane1.setSize((int)JPanel1.getMaximumSize().getWidth()-5,(int)JPanel1.getMaximumSize().getHeight()-5 );
topPanel.setBounds(0, 0, rightPanel.getWidth()-3, 25);
bottomPanel.setBounds(0,26,rightPanel.getWidth()-3,rightPanel.getHeight()-28);
sp.setSize((int)leftPanel.getMaximumSize().getWidth(),(int)leftPanel.getMaximumSize().getHeight());
sp.setAutoscrolls(true);
//sp.setSize((int)JSplitPane1.getLeftComponent().getBounds().getWidth()-2,(int)JSplitPane1.getLeftComponent().getBounds().getHeight()-2 );
sp.repaint();
//sp.setSize((int)leftPanel.getSize().getWidth(),(int)leftPanel.getSize().getHeight() );
void JFrame1_componentShown(java.awt.event.ComponentEvent event){
System.out.println("!!!");
JPanel1.setSize(this.getContentPane().getMaximumSize());
JSplitPane1.setSize((int)JPanel1.getMaximumSize().getWidth()-5,(int)JPanel1.getMaximumSize().getHeight()-5 );
topPanel.setBounds(0, 0, rightPanel.getWidth()-3, 25);
sp.setSize((int)JSplitPane1.getLeftComponent().getBounds().getWidth()-2,(int)JSplitPane1.getLeftComponent().getBounds().getHeight()-2 );
sp.repaint();
bottomPanel.setBounds(0,26,rightPanel.getWidth()-3,rightPanel.getHeight()-28);
}hi sculz,
i develped the tree, and tree selection listener also the 4 th point i didnt able to do . here is the code belo what i did.
iam not able to add the JSplit pane also.
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.*;
public class Tree08 extends JFrame{
Hashtable theHashtable = new Hashtable();
int frameWidth = 300;
int frameHeight = 305;
int numberRows = 19;
JTree tree;
JPanel treePanel;
String plafClassName =
"com.sun.java.swing.plaf.motif.MotifLookAndFeel";
For future reference, the three plaf implementations
are:
com.sun.java.swing.plaf.metal.MetalLookAndFeel
com.sun.java.swing.plaf.motif.MotifLookAndFeel
com.sun.java.swing.plaf.windows.WindowsLookAndFeel
JLabel display;
public static void main(String args[]) {
new Tree08();
public Tree08 () {
theHashtable.put("Cabbage","Good in slaw");
theHashtable.put("Squash","The yellow variety");
theHashtable.put("Onion","Not too hot");
theHashtable.put("Squirrel","Likes to store nuts");
theHashtable.put("Rabbit","Runs fast");
theHashtable.put("Fox","Crazy like a ...");
theHashtable.put("Horse","Fun to ride");
theHashtable.put("Pig","Lives in mud");
theHashtable.put("Cow","Gives us milk");
theHashtable.put("Peach","From Georgia");
theHashtable.put("Grape","Saueeze into wine");
theHashtable.put("Apple","Red delicious");
theHashtable.put("Orange","Very juicy");
DefaultMutableTreeNode[] theTreeNodes = new
DefaultMutableTreeNode[numberRows];
theTreeNodes[0] = new DefaultMutableTreeNode("Sample
Tree");
theTreeNodes[1] = new
DefaultMutableTreeNode("Vegetables");
theTreeNodes[2] = new
DefaultMutableTreeNode("Cabbage");
theTreeNodes[3] = new
DefaultMutableTreeNode("Squash");
theTreeNodes[4] = new
DefaultMutableTreeNode("Onion");
theTreeNodes[5] = new
DefaultMutableTreeNode("Animals");
theTreeNodes[6] = new
DefaultMutableTreeNode("Forrest");
theTreeNodes[7] = new
DefaultMutableTreeNode("Squirrel");
theTreeNodes[8] = new
DefaultMutableTreeNode("Rabbit");
theTreeNodes[9] = new DefaultMutableTreeNode("Fox");
theTreeNodes[10] = new
DefaultMutableTreeNode("Farm");
theTreeNodes[11] = new
DefaultMutableTreeNode("Horse");
theTreeNodes[12] = new DefaultMutableTreeNode("Pig");
theTreeNodes[13] = new DefaultMutableTreeNode("Cow");
theTreeNodes[14] = new
DefaultMutableTreeNode("Fruit");
theTreeNodes[15] = new
DefaultMutableTreeNode("Peach");
theTreeNodes[16] = new
DefaultMutableTreeNode("Grape");
theTreeNodes[17] = new
DefaultMutableTreeNode("Apple");
theTreeNodes[18] = new
DefaultMutableTreeNode("Orange");
theTreeNodes[0].add(theTreeNodes[1]);
theTreeNodes[1].add(theTreeNodes[2]);
theTreeNodes[1].add(theTreeNodes[3]);
theTreeNodes[1].add(theTreeNodes[4]);
theTreeNodes[0].add(theTreeNodes[5]);
theTreeNodes[5].add(theTreeNodes[6]);
theTreeNodes[6].add(theTreeNodes[7]);
theTreeNodes[6].add(theTreeNodes[8]);
theTreeNodes[6].add(theTreeNodes[9]);
theTreeNodes[5].add(theTreeNodes[10]);
theTreeNodes[10].add(theTreeNodes[11]);
theTreeNodes[10].add(theTreeNodes[12]);
theTreeNodes[10].add(theTreeNodes[13]);
theTreeNodes[0].add(theTreeNodes[14]);
theTreeNodes[14].add(theTreeNodes[15]);
theTreeNodes[14].add(theTreeNodes[16]);
theTreeNodes[14].add(theTreeNodes[17]);
theTreeNodes[14].add(theTreeNodes[18]);
treePanel = new TreePanel(theTreeNodes[0]);
tree.addTreeSelectionListener(new MyTreeListener());
Container content = getContentPane();
content.add(treePanel,BorderLayout.CENTER);
display = new JLabel("Display Selection Here");
content.add(display,BorderLayout.SOUTH);
setSize(frameWidth, frameHeight);
setTitle("Copyright 1998, R.G.Baldwin");
setVisible(true);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);}
class MyTreeListener implements TreeSelectionListener{
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode theNode =
(DefaultMutableTreeNode)
(e.getPath().getLastPathComponent());
if (theNode.isLeaf()) {
display.setText((String)theHashtable.get(
theNode.getUserObject()));
class TreePanel extends JPanel {
public TreePanel(TreeNode root){
setLayout(new BorderLayout());
tree = new JTree(root);
JScrollPane sp = new JScrollPane(tree);
add(sp, BorderLayout.CENTER);
try{
UIManager.setLookAndFeel(plafClassName);
}catch(Exception ex){System.out.println(ex);}
SwingUtilities.updateComponentTreeUI(this);
for(int cnt = 0; cnt < numberRows; cnt++){
tree.expandRow(cnt);
regards
sonali -
Parse and display xml doc when click on JTree node?
Ok so here is the code that I have now. You will have to make alot of html files to run the program, but they can be empty for now. What you can do is just put the same exact html file to be displayed in each node element. for example.
DefaultMutableTreeNode n1_node1_b1 =
new DefaultMutableTreeNode(new ModuleInfo("Device", "device.html"));could be changed to
DefaultMutableTreeNode n1_node1_b1 =
new DefaultMutableTreeNode(new ModuleInfo("Device", "status.html"));And just keep adding the status.html page to each one of the nodes.
anyway.
For now when I click on the node, the html file is displayed in the JScrollPane rPane = new JScrollPane(htmlPane); and the htmlPane is a JEditorPane
what I need it to do.
When I click on the JTree node. I would like to go out to an xml file, parse the information in it, and display it to the pane.
I will need to later, be able to add, edit, or delete information on the xml through the pane later.
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.JTree;
import javax.swing.JPanel;
import javax.accessibility.*;
import javax.swing.UIManager;
import javax.swing.JComponent;
import javax.swing.JEditorPane;
import javax.swing.tree.TreeSelectionModel;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.ImageIcon;
import java.net.URL;
import java.io.IOException;
import java.awt.Dimension;
* @author orozcom
public class Example extends JFrame implements TreeSelectionListener
private JEditorPane htmlPane;
private URL helpURL;
private static boolean DEBUG = false;
private JTree tree;
public Example()
super("Example");
setSize(1200,900);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JMenuBar jmb = new JMenuBar();
JMenu fileMenu = new JMenu("File");
JMenuItem openItem = new JMenuItem("Open");
JMenuItem saveItem = new JMenuItem("Save");
JMenuItem exitItem = new JMenuItem("Exit");
exitItem.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent ae)
System.exit(0);
fileMenu.add(openItem);
fileMenu.add(saveItem);
fileMenu.add(new JSeparator());
fileMenu.add(exitItem);
jmb.add(fileMenu);
setJMenuBar(jmb);
// **************** start JTree ******************//
JPanel lPane =new JPanel();
lPane.setLayout(new BorderLayout());
DefaultMutableTreeNode top = new DefaultMutableTreeNode(new ModuleInfo("Devices","splashScreen.html"));
DefaultMutableTreeNode branch1 =
new DefaultMutableTreeNode(new ModuleInfo("Module 1", "module1.html"));
DefaultMutableTreeNode branch2 =
new DefaultMutableTreeNode(new ModuleInfo("Module 2", "module2.html"));
//DefaultMutableTreeNode branch3 =
//new DefaultMutableTreeNode(new ModuleInfo("Module 3", "module3.html"));
//adding to the topmost node
top.add(branch1);
top.add(branch2);
//top.add(branch3);
* BRANCH 1 *
//adding to the First branch
DefaultMutableTreeNode node1_b1
=new DefaultMutableTreeNode(new ModuleInfo("Status", "status.html"));
//branch1.add(node1_b1);
DefaultMutableTreeNode n1_node1_b1 =
new DefaultMutableTreeNode(new ModuleInfo("Device", "device.html"));
DefaultMutableTreeNode n2_node1_b1 =
new DefaultMutableTreeNode(new ModuleInfo("Network", "network.html"));
DefaultMutableTreeNode n3_node1_b1 =
new DefaultMutableTreeNode(new ModuleInfo("Chassis", "chassis.html"));
DefaultMutableTreeNode n4_node1_b1 =
new DefaultMutableTreeNode(new ModuleInfo("Resources", "resources.html"));
node1_b1.add(n1_node1_b1);
node1_b1.add(n2_node1_b1);
node1_b1.add(n3_node1_b1);
node1_b1.add(n4_node1_b1);
DefaultMutableTreeNode node2_b1 =
new DefaultMutableTreeNode(new ModuleInfo("Project Editor", "projedit.html"));
DefaultMutableTreeNode node3_b1 =
new DefaultMutableTreeNode(new ModuleInfo("Project Manager", "projmngt.html"));
DefaultMutableTreeNode node4_b1 =
new DefaultMutableTreeNode(new ModuleInfo("Administration", "administration.html"));
DefaultMutableTreeNode n1_node4_b1 =
new DefaultMutableTreeNode(new ModuleInfo("Device", "device.html"));
DefaultMutableTreeNode n2_node4_b1 =
new DefaultMutableTreeNode(new ModuleInfo("Network", "network.html"));
DefaultMutableTreeNode n3_node4_b1 =
new DefaultMutableTreeNode(new ModuleInfo("Users", "users.html"));
node4_b1.add(n1_node4_b1);
node4_b1.add(n2_node4_b1);
node4_b1.add(n3_node4_b1);
DefaultMutableTreeNode node5_b1 =
new DefaultMutableTreeNode(new ModuleInfo("Logging", "logging.html"));
branch1.add(node1_b1);
branch1.add(node2_b1);
branch1.add(node3_b1);
branch1.add(node4_b1);
branch1.add(node5_b1);
* BRANCH 2 *
//adding to the Second branch
DefaultMutableTreeNode node1_b2 =
new DefaultMutableTreeNode(new ModuleInfo("Status", "status.html"));
DefaultMutableTreeNode n1_node1_b2 =
new DefaultMutableTreeNode(new ModuleInfo("Device", "device.html"));
DefaultMutableTreeNode n2_node1_b2 =
new DefaultMutableTreeNode(new ModuleInfo("Network", "network.html"));
DefaultMutableTreeNode n3_node1_b2 =
new DefaultMutableTreeNode(new ModuleInfo("Chassis", "chassis.html"));
DefaultMutableTreeNode n4_node1_b2 =
new DefaultMutableTreeNode(new ModuleInfo("Resources", "resources.html"));
node1_b2.add(n1_node1_b2);
node1_b2.add(n2_node1_b2);
node1_b2.add(n3_node1_b2);
node1_b2.add(n4_node1_b2);
DefaultMutableTreeNode node2_b2=
new DefaultMutableTreeNode(new ModuleInfo("Project Editor", "projedit.html"));
DefaultMutableTreeNode node3_b2=
new DefaultMutableTreeNode(new ModuleInfo("Project Manager", "projmngt.html"));
DefaultMutableTreeNode node4_b2=
new DefaultMutableTreeNode(new ModuleInfo("Administration", "administration.html"));
DefaultMutableTreeNode n1_node4_b2=
new DefaultMutableTreeNode(new ModuleInfo("Device", "device.html"));
DefaultMutableTreeNode n2_node4_b2=
new DefaultMutableTreeNode(new ModuleInfo("Network", "network.html"));
DefaultMutableTreeNode n3_node4_b2=
new DefaultMutableTreeNode(new ModuleInfo("Users", "users.html"));
node4_b2.add(n1_node4_b2);
node4_b2.add(n2_node4_b2);
node4_b2.add(n3_node4_b2);
DefaultMutableTreeNode node5_b2=
new DefaultMutableTreeNode(new ModuleInfo("Logging", "logging.html"));
branch2.add(node1_b2);
branch2.add(node2_b2);
branch2.add(node3_b2);
branch2.add(node4_b2);
branch2.add(node5_b2);
* BRANCH 3 *
//adding to the Third branch
DefaultMutableTreeNode node1_b3=new DefaultMutableTreeNode("Status");
DefaultMutableTreeNode n1_node1_b3=new DefaultMutableTreeNode("Device");
DefaultMutableTreeNode n2_node1_b3=new DefaultMutableTreeNode("Network");
DefaultMutableTreeNode n3_node1_b3=new DefaultMutableTreeNode("Chassis");
DefaultMutableTreeNode n4_node1_b3=new DefaultMutableTreeNode("Resources");
node1_b3.add(n1_node1_b3);
node1_b3.add(n2_node1_b3);
node1_b3.add(n3_node1_b3);
node1_b3.add(n4_node1_b3);
DefaultMutableTreeNode node2_b3=new DefaultMutableTreeNode("Project Editor");
DefaultMutableTreeNode node3_b3=new DefaultMutableTreeNode("Project Manager");
DefaultMutableTreeNode node4_b3=new DefaultMutableTreeNode("Administration");
DefaultMutableTreeNode n1_node4_b3=new DefaultMutableTreeNode("Device");
DefaultMutableTreeNode n2_node4_b3=new DefaultMutableTreeNode("Network");
DefaultMutableTreeNode n3_node4_b3=new DefaultMutableTreeNode("Users");
node4_b3.add(n1_node4_b3);
node4_b3.add(n2_node4_b3);
node4_b3.add(n3_node4_b3);
DefaultMutableTreeNode node5_b3=new DefaultMutableTreeNode("Logging");
branch3.add(node1_b3);
branch3.add(node2_b3);
branch3.add(node3_b3);
branch3.add(node4_b3);
branch3.add(node5_b3);
tree=new JTree(top,true);
//tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);
//Set the icon for leaf nodes.
ImageIcon deviceIcon = createImageIcon("/device.gif");
if (deviceIcon != null)
DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
renderer.setLeafIcon(deviceIcon);
tree.setCellRenderer(renderer);
else
System.err.println("Leaf icon missing; using default.");
//Listen for when the selection changes.
tree.addTreeSelectionListener(this);
//Create the scroll pane and add the tree to it.
//JScrollPane treeView = new JScrollPane(tree);
tree.setToolTipText(" and ");
lPane.add(tree);
getContentPane().add(lPane);
// **************** end JTree ******************//
htmlPane = new JEditorPane();
htmlPane.setEditable(false);
initHelp();
JScrollPane rPane = new JScrollPane(htmlPane);
JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, lPane, rPane);
jsp.setDividerLocation(180);
getContentPane().add(jsp, BorderLayout.CENTER);
JPanel bPane = new JPanel();
JButton okButton = new JButton("Ok");
JButton applyButton = new JButton("Apply");
JButton clearButton = new JButton("Clear");
bPane.add(okButton);
bPane.add(applyButton);
bPane.add(clearButton);
getContentPane().add(bPane, BorderLayout.SOUTH);
setVisible(true);
/** Required by TreeSelectionListener interface. */
public void valueChanged(TreeSelectionEvent e)
DefaultMutableTreeNode node = (DefaultMutableTreeNode)
tree.getLastSelectedPathComponent();
if (node == null) return;
Object nodeInfo = node.getUserObject();
if (node.isLeaf())
ModuleInfo module = (ModuleInfo)nodeInfo;
displayURL(module.moduleURL);
if (DEBUG)
System.out.print(module.moduleURL + ": \n ");
else
displayURL(helpURL);
if (DEBUG)
System.out.println(nodeInfo.toString());
private class ModuleInfo
public String deviceName;
public URL moduleURL;
public ModuleInfo(String device, String filename)
deviceName = device;
moduleURL = (URL)Example.class.getResource("/" + filename);
if (moduleURL == null)
System.err.println("Couldn't find file: "
+ filename);
public String toString()
return deviceName;
private void initHelp()
String s = "YFDemoHelp.html";
helpURL = Example.class.getResource("/" + s);
if (helpURL == null)
System.err.println("Couldn't open help file: " + s);
else if (DEBUG)
System.out.println("Help URL is " + helpURL);
displayURL(helpURL);
private void displayURL(URL url)
try
if (url != null)
htmlPane.setPage(url);
else
{ //null url
htmlPane.setText("File Not Found");
if (DEBUG)
System.out.println("Attempted to display a null URL.");
catch (IOException e)
System.err.println("Attempted to read a bad URL: " + url);
/** Returns an ImageIcon, or null if the path was invalid. */
protected static ImageIcon createImageIcon(String path)
java.net.URL imgURL = Example.class.getResource(path);
if (imgURL != null)
return new ImageIcon(imgURL);
else
System.err.println("Couldn't find file: " + path);
return null;
public static void main(String args[])
new Example();
//new AssistiveExample();
}Thanks orozcomyes i can at the time of MIRO u can see both
go in SU01 for and user
in Parameters enter IVFIDISPLAY in Parameter ID and X in Paramater Value
thus for that user u will be able to c Invoice number and accounting number after saving MIRo
u will get message like
Invoice document 5105608893 was posted ( Accountng Documnt: 5100000000 )
hope this helps
Maybe you are looking for
-
SSO Login page Error : Unexpected errors (WWC-41400)
Hi, I downloaded the zip file ssosdk.zip from download section of OTN for SSO and followed the steps in the Install document. All the process went through without any error. But when i tried to access my login URL, i am getting this error :Unexpected
-
Calling action listener for a BUTTON component in java bean page
Hi, I have made it like this. public void handleButtonPressed(ActionEvent event){ System.out.println("success!!!!!"); //code for calling actionlistener FacesContext fctx = FacesContext.getCurrentInstance(); ELContext elctx = fctx.getELContext(); Appl
-
DOES THIS SOUND LIKE THE MOTHERBOARD PROBLEM? GPU? COMPUTER WILL START: I CAN HEAR FAN ETC. LIGHTS ARE ON THE KEY BOARD. SCREEN IS BLACK. I REVERSED THE THE RAM CHIPS POSITION I CONNECTED THE LAPTOP TO AN EXTERNAL MONITOR THESE ACTIONS PRODUCED NOTH
-
I am unable to access 3G network, although wireless access is working fine. When opening a page in safari it churns for a while and then says that server has stopped responding. I noticed on one forum that it said something about changing brightnes
-
Error Code:9 Failed to connect to Native Directory
Hello everyone I am getting this kind of error "Error Code:9 Failed to connect to Native Directory" while I am trying to open shared services console. I am not even able to open the EPM System Configurator. Please provide me some suggestions on this.