How to solve the tree update problem

Hi all,
I met a urgent problem, I defined two tree control over two JScrollPanes.
two JScrollPanes are in a JSplitPane which is located in another JSplit's left. The left JSplitPane and another JTextarea both are in another JSplitPane.they are layouted as:
JTree1 | JTextArea
JTree2 | JTextArea
I want to achieve this: when I clicked a node in JTree1,then JTree2 is changed in the viewport according to the content of the clicked node.
I use the following essential code :
public class TNTree extends JTree {
private TemplateFrame frame1;
public TNTree(TemplateFrame frame/*,XTree tree*/)
this.frame1=frame;
getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
setShowsRootHandles(true);
setEditable(false);
try{
treeModel=initTree();
setModel(treeModel);
jbInit();
}catch(Exception e){}
this.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e) {
TreePath tp=getPathForLocation(e.getX(), e.getY());
pt.x=e.getX();
pt.y=e.getY();
try{
if((e.getModifiers()&InputEvent.BUTTON1_MASK)==InputEvent.BUTTON1_MASK)
setSelectionPath(tp);
if(e.getClickCount()==1){
if((tp!=null)&&(!isIn((DefaultMutableTreeNode)tp.getLastPathComponent())))
{    tempStr=((DefaultMutableTreeNode)tp.getLastPathComponent()).toString();
Connection con=getConnection();
PreparedStatement pstmt;
pstmt=con.prepareStatement("select content from template ,tcontent"+
" where template.tcode=tcontent.tcode and name=?");
pstmt.setString(1,tempStr);
ResultSet rset=pstmt.executeQuery();
String str="";
if(rset.next()){
str=rset.getString(1);
treeStr=str;
System.out.println(treeStr);
// frame1.xTree =new XTree(frame1,str);
// frame1.xTree=new XTree(frame1);
frame1.xTree.refresh( str );
frame1.jScroll.getViewport().add(frame1.xTree);
// frame1.repaint();
if(e.getClickCount()==2){
}else
}catch(Exception e1){e1.printStackTrace();}
public class XTree extends JTree {
private TemplateFrame frame;
public XTree(TemplateFrame frame) throws ParserConfigurationException
this.frame=frame;
refreshTextFlag=false;
strBuffer=new StringBuffer();
     getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
     setShowsRootHandles( true );
     setEditable( false );
     dbf = DocumentBuilderFactory.newInstance();
     dbf.setValidating( false );
     db = dbf.newDocumentBuilder();
treeModel = buildWelcomeTree();
setModel(treeModel );
TreeTXT = "";
try{
jbInit();
catch(Exception e){
//e.printStackTrace();
Error err = new Error();
eBuffer.append(err.getValue("Err#4"));
eBuffer.append("\r\n");
public void refresh( String text ) //throws ParserConfigurationException
try{
treeModel=buildTree(text);
setModel( treeModel );
TreeTXT = text;
}catch(Exception e){
// e.printStackTrace();
Error err = new Error();
eBuffer.append(err.getValue("Err#1"));
eBuffer.append("\r\n");
public class TemplateFrame extends JFrame
static XTree xTree=null;
static TNTree tnTree;
xTree=new XTree(this);
tnTree=new TNTree(this);
jScrollLeft.getViewport().add(tnTree);
void fileOpen_ActionPerformed(ActionEvent e)
String fileName = "";
BufferedReader reader;
String line;
StringBuffer xmlText;
JFileChooser chooser = new JFileChooser();
Container parent = jMenuItem4.getParent();
int choice = chooser.showOpenDialog(parent);
int returnVal = chooser.showOpenDialog(this);
if(returnVal == JFileChooser.APPROVE_OPTION) {
textMessage.setText("You chose to open this file: " +
chooser.getSelectedFile().getAbsolutePath() );
// chooser.getSelectedFile().getName());
fileName = chooser.getSelectedFile().getAbsolutePath();
path=fileName;
if(fileName.substring(fileName.length()-3,fileName.length()).equalsIgnoreCase("xml"))
//Will fix future
try{
reader = new BufferedReader( new FileReader( fileName ) );
xmlText = new StringBuffer();
while ( ( line = reader.readLine() ) != null )
xmlText.append( line+"\n" );
reader.close();
//refresh the xml tree
xTree.refresh( xmlText.toString() );
textArea.setText( xmlText.toString() ) ;
/*Set the title*/
//fTitle = chooser.getSelectedFile().getName();
fTitle = chooser.getSelectedFile().getName();
this.setTitle(fTitle/*+mTitle */ );
//Sign the editor has a file
dirty = true;
}catch(Exception Mye) {
textMessage.setText("Error occured when opening the file");
}else{
textMessage.setText("Error occured when the opening file is not a xml file");
Now my problem is when in TemplateFrame cl*** I call open method including import xTree.refresh(string),I can get the right results ,the JTree2 is refreshed correctly,but when in TNTree cl*** I call the xTree.refresh(String),I met a java.lang.nullpointer exception , How can I solve this problem?
Are there other better ways to slove this problem?

Hm ...
what should it be otherwise?- You said, the problem is calling frame1.xTree.refresh(str) - and the NullPointerException is thrown there - so there are only 2 possibilities - frame1 is null or xTree is null. So please add the following code before this line ...
if (frame1==null) { System.out.println("frame1 is null"); }
else if (frame1.xTree==null) { System.out.println("frame1.xTree is null"); }
else System.out.println("None of them is null - I haven't read the runtime error correctly");and then you will see, where the problem is :)
greetings Marsian

Similar Messages

  • HT1212 How to solve the forgotten passcode problem

    If I never connect my iPhone5 to iTunes, didnt turn on the iCloud, and did not backup my phone before, how can i solve the forgotten passcode problem without erasing the data?

    Read the article that brought you here
    http://support.apple.com/kb/ht1212 
    There is nothing you can do other than that and you will lose your data if you have never backed up

  • How to solve the wifi dropping problem on Att UVerse.

    Today with aid from others on the forums and help from apple I figured out how to stop the problem where your iPad will drop wifi while your using it.
    Wat was wrong before:
    While surfing the web my wifi would disconnect, and I would have to go to settings>wifi and turn It off and then back on, this would happen every two to three minutes.
    YouTube videos would load very fast and about half way would stop and need to buffer.
    When streaming pandora, it would only be be able to play one song, before needing to restart the Internet.
    My router:
    I have a homeportal 3000 router through AT&T
    http://www.convergedigest.com/images/articles/v12n140-2wire.jpg
    First you will need to know your account password for Uverse.
    On the side of the router it will tell you system password, key, and Mac ID, at the top it will say for more info visit and there will be a number separated by some periods.
    Go to that link, (on either your iPad or any computer)
    When you get there you should see the name of your router and how it's performing.
    At the top there will be four tabs, click on settings.
    Six more tabs will pop up below the two tabs, click LAN.
    Below the six tabs, another six tabs will appear, click wireless.
    Scroll down and find security.
    Under authentication type, change it to "WPA2-PSK (AES)"
    Scroll down to the bottom and click save, it should then ask you for your password. NOTE: this is your uverse password, not the password on your router.
    There should be a green box that says you were successful.
    I've been going five hours now and havn't had one disconnect.
    Thanks and hope this helps.

    Thanks, this has been driving me crazy on both my MacBook and iPhone. It was dropping my wifi every few seconds! Changed the Authentication Type to WPA2-PSK (AES) and wow! It's been at least 2 entire minutes without dropping!

  • How to solve the image display problem in the iTunes Store

    Hi guys!
    I just want to give a work-around for all of you having the image display problem in the iTunes Store. In my case only the square images in the slider sections won't load:
    I had this in my last W7-installation and got it again in W8 after the first few weeks.
    There are a lot of reports about this problem out there and adhoc solutions like 'clear the cache' or 'reinstall and drink ice tea' that do not work. It is obviously a file request error. It is all about finding out which server addresses get blocked by your computer.
    Solution: Go to your firewall and your Anti-virus-program. There must be a whitelist option. In Kaspersky, check the web-options, the banner-options and the firewall-options, because the all have whitelists. The following addresses have to be whitelisted:
    *.apple
    *.mzstatic.apple.com.akadns.net
    *.mzstatic.com.edgesuite.net
    *.da1.akamai.net
    *.itunes.apple.com
    se.itunes.apple.com
    upp.itunes.apple.com
    ax.init.itunes.apple.com
    xp.apple.com
    *.mzstatic.com
    client-api.itunes.apple.com
    www.apple.com.edgekey.net
    www.isg-apple.com.akadns.net
    Press Ctrl + R in the iTunes Shop then and browse throught the music sections. All images should be displayed correctly now.
    If not, there might be more Apple servers involved in your case. You can find them by running a DNS sniffing tool like the DNS query sniffer by Nirsoft or Wireshark.

    Phone restarting randomly could be loose battery. Tighten by putting a small strip of electrical tape on the back edge.
    THE BITTERNESS OF POOR QUALITY, LINGERS LONG AFTER THE CHEAPNESS OF PRICE, IS SOON FORGOTTEN.

  • How to solve the webkit2webprocess.exe problem ?

    my computer is a pc with windows xp and I'm using Safari as my browser and it keeps crashing due to a webkit2webprocess.exe error how do I get past this problem ?

    how do I get past this problem ?
    By uninstalling Safari. It's long discontinued on Windows, unsupported, buggy, and probably unsafe to use.

  • How to solve the ethernet driver problem

    Hi,
    My desktop consist of harddisk capacity of 300gp,which consist of the OS windows xp.
    Now i need to remove windows xp and i want to install oel5 only.
    But my problem is with the ethernet driver because while i work with windows xp i have no ethernet driver so i installed it seperately and everything is worked fine.
    And my question is if i install only oel5 wheather the same problem will exist or not then how i can download the ethernet driver software of oel5
    please help me

    user8818950  wrote:
    Hi,
    My desktop consist of harddisk capacity of 300gp,which consist of the OS windows xp.
    Now i need to remove windows xp and i want to install oel5 only.install it from cd/dvd.do you need network installation?
    >
    But my problem is with the ethernet driver because while i work with windows xp i have no ethernet driver so i installed it seperately and everything is worked fine.
    to solute out this we need to see output of lspci and lsmod (or the manufacture hex code from xp also work.)
    And my question is if i install only oel5 wheather the same problem will exist or not then how i can download the ethernet driver software of oel5
    its depend on the vendor id of the NIC.so put your lspci output after the installation of OEL5.4.In general OEL5.4 may give/detect the NIC by its own.
    >
    >
    please help me

  • How to solve the error 2 problem

    How to I solve this? I need bonjour and all that other **** too. Only itunes downloaded.

    With the Error 2, let's try a standalone Apple Application Support install. It still might not install, but fingers crossed any error messages will give us a better idea of the underlying cause of the issue.
    Download and save a copy of the iTunesSetup.exe (or iTunes64setup.exe) installer file to your hard drive:
    http://www.apple.com/itunes/download/
    Download and install the free trial version of WinRAR:
    http://www.rarlab.com/download.htm
    Right-click the iTunesSetup.exe (or iTunes64Setup.exe), and select "Extract to iTunesSetup" (or "Extract to iTunes64Setup"). WinRAR will expand the contents of the file into a folder called "iTunesSetup" (or "iTunes64Setup").
    Go into the folder and doubleclick the AppleApplicationSupport.msi to do a standalone AAS install.
    Does it install properly for you?
    If instead you get an error message during the install, let us know what it says. (Precise text, please.)

  • How to solve the " Unknown error" problem

    hi
     can anybody help me to solve " unknown error problem" of blackberry Z10 with "X" symbol at top right of the screen with red color.
    And remaining all services (Wifi) are working except the calls.
    And also my phone is automatically restarting frequently.
    please help me in this regard

    Phone restarting randomly could be loose battery. Tighten by putting a small strip of electrical tape on the back edge.
    THE BITTERNESS OF POOR QUALITY, LINGERS LONG AFTER THE CHEAPNESS OF PRICE, IS SOON FORGOTTEN.

  • Here are the instructions on how to fix the newest update problem with the .dll error message:, Here are the instructions on how to fix the newest update problem with the .dll error message:

    Go to My Computer, Uninstall Programs, and uninstall in this exact order :
          Itunes
          Apples Software Update
         Apple Mobile Device Support
         Bonjour (my system required a reboot on this one)
         Apple Application Support
    Reboot your computer, go to the official Itunes website (make sure it's the Apple Itunes Website and not some other one!), and reinstall Itunes. 
    I got the same .dll error message after the reinstall, but my Itunes was downloaded successfully and I was able to Sync my phone. : )
    Good luck to you and God Bless! 
    (Sad that we have to come to the Discussion Forum to figure this all out instead of Apple taking care of their business and helping us out, huh?)

    Someone else said they did a system restore to a previous update, and then a java update and that worked for them, saying they were going to stick with the earlier version of itunes until they get the bugs out of the new one.  I t tried restores and that didn't work for me either, but maybe it will work for you.  Good luck and I hope you get it working soon.. 

  • I try to update my apps but I get the following message: 'Your account is not valid for use in the Ireland store. You must switch to the Polish store.' I've never been using Polish store only Irish.. How to solve the problem?

    I try to update my apps but I get the following message: 'Your account is not valid for use in the Ireland store. You must switch to the Polish store.' I've never been using Polish store only Irish.. How to solve the problem?

    Try going to the bottom of the Featured tab in the App Store app on your device and tap on your account id, tap on 'View Apple ID' on the popup and log into your account, and then select the Country/Region section and select Ireland.

  • I update I cloud in my computer but i forget plug my device iphone 5s in my computer, suddenly my device shut down automatically, what's wrong, now I can turn on my iphone 5s. How I solve the problem

    I update  icloud in my computer but i forget plug my device iphone 5s in my computer, suddenly my device shut down automatically, what's wrong, now I can turn on my iphone 5s. How I solve the problem

    Hi fransiscasanti28,
    If you are unable to power on your iPhone you may want to troubleshoot using the steps in this article -
    iPhone: Hardware troubleshooting
    http://support.apple.com/kb/TS2802
    Specifically -
    Will not turn on, will not turn on unless connected to power, or unexpected power off
    Verify that the Sleep/Wake button functions. If it does not function, inspect it for signs of damage. If the button is damaged or is not functioning when pressed, seek service.
    Check if a Liquid Contact Indicator (LCI) is activated or there are signs of corrosion. Learn about LCIs and corrosion.
    Connect the iPhone to the iPhone's USB power adapter and let it charge for at least ten minutes.
    After at least 30 minutes, if:
    The home screen appears: The iPhone should be working. Update to the latest version of iOS if necessary. Continue charging it until it is completely charged and you see this battery icon in the upper-right corner of the screen . Then unplug the phone from power. If it immediately turns off, seek service.
    The low-battery image appears, even after the phone has charged for at least 20 minutes: See "iPhone displays the low-battery image and is unresponsive" symptom in this article.
    Something other than the Home screen or Low Battery image appears, continue with this article for further troubleshooting steps.
    If the iPhone did not turn on, reset it while connected to the iPhone USB power adapter.
    If the display turns on, go to step 4.
    If the display remains black, go to next step.
    Connect the iPhone to a computer and open iTunes. If iTunes recognizes the iPhone and indicates that it is in recovery mode, attempt to restore the iPhone. If the iPhone doesn't appear in iTunes or if you have difficulties in restoring the iPhone, see this article for further assistance.
    If restoring the iPhone resolved the issue, go to step 4. If restoring the iPhone did not solve the issue, seek service.
    Thanks for using Apple Support Communities.
    Best,
    Brett L

  • HT201210 how to solve the problem while re storing iphone 3gs. unknon erron occured(29)

    How to solve the problem while restoring iphone 3gs? (unknon error occured (29)

    Hello Musthafa K.O.M,
    Thank you for using Apple Support Communities.
    For more information, take a look at:
    Resolve specific iTunes update and restore errors
    http://support.apple.com/kb/ts3694#47
    Check for hardware issues
    Try to restore your iOS device two more times while connected with a cable, computer, and network you know are good. Also, confirm your security software and settings are allowing communication between your device and update servers. If you still see the alert when you update or restore, contact Apple support.
    Common errors: 1, 10-47, 1002, 1011, 1012, 1014, 1000-1020.
    Have a nice day,
    Mario

  • How to solve the problem related with inputing of the text into Wordpress from Firefox 9 and 9.0.1. The problem is that after inputing the formatting gets lost. Taking in account high popularity of Wordpress I suppose the problem is quite serious.

    How to solve the problem related with inputing of the text into Wordpress from Firefox 9 and 9.0.1.
    The problem is that after inputing the formatting gets lost.
    Taking in account high popularity of Wordpress I suppose the problem is quite serious.

    Perform the suggestions mentioned in the following articles:
    * [https://support.mozilla.com/en-US/kb/Template:clearCookiesCache/ Clear Cookies & Cache]
    * [[Troubleshooting extensions and themes]]
    * Clipboard not working -> [http://kb.mozillazine.org/Clipboard_not_working]
    * Rich Text Editing -> [http://kb.mozillazine.org/Rich_text_editing]
    * Update All your Firefox Plugins -> [https://www.mozilla.org/en-US/plugincheck/]
    Check and tell if its working.
    Might not be related to your problem but some of your Plugins are out-dated
    * Update All your Firefox Plugins -> [https://www.mozilla.org/en-US/plugincheck/]
    * '''When Downloading Plugins Update setup files, Remove Checkmark from Downloading other Optional Softwares with your Plugins (e.g. Toolbars, McAfee, Google Chrome, etc.)'''

  • Hello, I just got an iPhone 4S and it seems that the bluetooth function in it doesn't work. I tried few times to pair it to other non Apple phones and it never worked. Does anyone has an idea how to solve the problem? Tks.

    Hello, I just got an iPhone 4S and it seems that the bluetooth function in it doesn't work. I tried few times to pair it to other non Apple phones but it never worked. Does anyone has an idea how to solve the problem? Tks.

    This is not a feature of iPhone, iPad or iOS.
    Bluetooth is supported for stereo headsets/speakers, handsfree telephone
    devices/headsets, some keyboards, some peer-to-peer apps from the
    app store and internet tethering where provided by the carrier.
    Other than this it will not connect to a phone/computer/device.  (thanks to ckuan for the wording)

  • How to solve the problem when opening program illustrator cs6 ERROR: 16 It is WINDOWS 8.1 / 64 BIT help please

    how to solve the problem when opening program illustrator cs6
    ERROR: 16
    It is WINDOWS 8.1 / 64 BIT
    help please

    Thanks, Jeff! The file Adobe Setup Error.log contains the following information:
    02/14/14 07:20:26:474 | [INFO] |  | OOBE | DE |  |  |  | 8860 | DEVersion: 5.0.0.0
    02/14/14 07:20:26:475 | [INFO] |  | OOBE | DE |  |  |  | 8860 | Loading library from C:\Program Files (x86)\Common Files\Adobe\OOBE\PDApp\DECore\DE5\Setup.dll
    [    8860] Fri Feb 14 07:20:26 2014  INFO
    ::START TIMER:: [Total Timer]
    CHECK: Single instance running
    CHECK : Credentials
    Load Deployment File
    CHECK : Another Native OS installer already running
    Create Required Folders
    Assuming uninstall mode
    Lookup for master payload
    [    8860] Fri Feb 14 07:20:26 2014 ERROR
    DW040: The product "{893B3B44-0A1E-404B-8FE8-0A74509102A9}" is not installed. Cannot proceed with the uninstall
    [    8860] Fri Feb 14 07:20:26 2014  INFO
    :: END TIMER :: [Total Timer] took 6.90443 milliseconds (0.00690443 seconds) DTR = 579.338 KBPS (0.56576 MBPS)
    -------------------------------------- Summary --------------------------------------
    - 0 fatal error(s), 1 error(s), 0 warning(s)
    ERROR: DW040: The product "{893B3B44-0A1E-404B-8FE8-0A74509102A9}" is not installed. Cannot proceed with the uninstall
    Please search the above error/warning string(s) to find when the error occurred.
    These errors resulted in installer Exit Code mentioned below.
    Exit Code: 33 - The product is not installed, cannot uninstall.
    Please see specific errors and warnings for troubleshooting. For example, ERROR: DW040 ...

Maybe you are looking for

  • Update adress data of customers

    Hi there, I created a dialog application for creating or changing customer data. The changes must be released by the head of the financial department. The data are stored in separate data tables. When a changed or new customer is released the dialog

  • IPad won't play videos

    I have downloaded a few videos from my iTunes onto my iPad and when I click on them all appears well and the time bar along the top counts up as if its playing the film however it's just a blank screen. I have tried removing them from my iPad and rel

  • PPro CS5: Titles have wrong color and thickness in Timeline

    Hi there if i'm writing a Title in PPro CS5, everything is ok and like in PPro CS4 in the Title-Window. Then i'm changing to the Timeline and the Title gets bright and thin in the Program Window. The Title has not it's origin color, as selected in th

  • UBS 3.0 Drive Missing from Windows Explorer after Drive Sleeps

    I have an external USB 3.0 Hard drive that is present when the computer first starts up but is missing when the drive sleeps.  I have to restart the computer to see the drive again.  Is there a driver update or setting that I'm missing? HP ENVY Phoen

  • Button component wierdness

    Player.fla and Controller.as are in the same folder. Player.fla: Button component in the library (with its assets). Document Class = "Controller". 1 layer, 1 frame. No code in timeline. Controller.as: (see attached code) My problem: I put a button on