Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » WB uses wrong Classpath(Parsing seems to use the wrong classpath for embedded Components)
WB uses wrong Classpath [message #1101542] Wed, 04 September 2013 15:43 Go to next message
Stefan Schuh is currently offline Stefan SchuhFriend
Messages: 2
Registered: September 2013
Junior Member
Hi!

I'm facing the problem that a FileNotFoundException is thrown in my MainFrame, when I open the design page. I've written small test classes, which isolate the problem and I will explain my issue based on my example.

My Test-MainFrame looks like this:
package test;

import javax.swing.JFrame;

public class Testframe extends JFrame {
    
    /**  */
    private static final long serialVersionUID = -7304518081501850501L;
    
    public Testframe() {
        this.getRootPane().add(new Testpanel());
    }
}


In my application an embedded panel loads some combo box values from a file. If an error occurs it shows a message to the user, that the file could not be loaded.
In my example the embedded panel just opens a file:
package test;

import java.io.File;

public class Testpanel extends JPanel {
    
    /**  */
    private static final long serialVersionUID = -8125209595694433094L;
    
    public Testpanel() {
        try {
            new FileInputStream(new File("settings/test.txt"));
        } catch (FileNotFoundException e) {
            JOptionPane.showMessageDialog(this, "Error Reading test.txt!" + e, "File Error", JOptionPane.ERROR_MESSAGE);
        }
    }
}


The settings folder is within my Testproject. (Testproject/settings/test.txt)
If I run the frame with Java I get no error:
package test;

public class Main {
    public static void main(String[] args) {
        new Testframe().setVisible(true);
    }
}


If I open the design page of Testframe I get the error message popup. The problem seems to be the classpath. WB searches the file in my eclipse directory.
From what I've read in the forum, WB should use the project classpath.

For clarification: This issue is just nasty for me and I will try the $hide$ annotations, but I thought you're interested in it and want to fix it ; )
Re: WB uses wrong Classpath [message #1101729 is a reply to message #1101542] Wed, 04 September 2013 22:09 Go to previous messageGo to next message
Eric Clayberg is currently offline Eric ClaybergFriend
Messages: 882
Registered: July 2009
Location: Boston, MA
Senior Member
You should read the WindowBuilder FAQ section on "Can WindowBuilder Pro use custom widgets?" and use of Beans.isDesignTime(). The following is the relevant part:

Quote:
Note: A component may rely on some runtime behavior that is not possible at design time (such as accessing an application database or some other file). Runtime specific behavior should be isolated (and stubbed out as necessary) by wrappering the runtime specific code with a call to Beans.isDesignTime() which will answer true when the component is loaded within WindowBuilder Pro and false at runtime.

Re: WB uses wrong Classpath [message #1101978 is a reply to message #1101729] Thu, 05 September 2013 07:13 Go to previous message
Stefan Schuh is currently offline Stefan SchuhFriend
Messages: 2
Registered: September 2013
Junior Member
Many Thanks for the fast reply and the hint.
Previous Topic:Move components with arrow keys in WindowBuilder
Next Topic:Restrict usage of few Palette objects from dropping onto ViewPart canvas
Goto Forum:
  


Current Time: Fri Nov 21 04:30:46 GMT 2014

Powered by FUDForum. Page generated in 0.01650 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software