This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 5 - Pages: 1 - Last Post: 5 Feb 21, 10:41 Last Post By: davidekholm
AndreWolff

Posts: 1,289
Registered: 14-Dec-2007
How to use an item declared in the main module in custom panel code?
Posted: 4 Feb 21, 09:09
 
  Click to reply to this thread Reply
In the compiled FancyBox GUI I have two files: the main module FancyBox.java and the custompanel code in FancyBoxCustomUI.java
In FancyBoxCustomUI.java I like to use a filefilter gpsFilter defined in FancyBox.java:
          linkTracklogSelector.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                getRelativePath(linkTracklogFolder, gpsFilter);
            }
        });


Both getRelativePath and gpsFilter are declared in FancyBox.java, but only gpsFilter get a red line (cannot find symbol).
If I copy the filter code to FancyBoxCustomUI.java:
        FileFilter gpsFilter = new FileNameExtensionFilter("GPS files", new String[]{"gpx", "zip"});
I get also a red line below getRelativePath

I tried already FancyBox.gpsFilter and import FancyBox.* without succes.

What is the correct method?

Sorry for this stupid question, but I am no JAVA programmer.

davidekholm

Posts: 3,440
Registered: 18-Oct-2002
Re: How to use an item declared in the main module in custom panel code?
Posted: 4 Feb 21, 13:14   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
Hard to tell without the context for these declarations. Can you attach the source files?
AndreWolff

Posts: 1,289
Registered: 14-Dec-2007
Re: How to use an item declared in the main module in custom panel code?
Posted: 4 Feb 21, 17:26   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Attachment FancyBox.zip (175.0 KB)
davidekholm wrote:
Can you attach the source files?
Yes, see attached zip file
davidekholm

Posts: 3,440
Registered: 18-Oct-2002
Re: How to use an item declared in the main module in custom panel code?
Posted: 4 Feb 21, 23:45   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
Attachment FancyBox.zip (47.7 KB)
See updated zip file.
I've made the following changes to solve your problems:
  • Made FancyBox.relativePath package-private instead of private so it can be reached from FancyBoxCustomUI
  • Made all file filters static so they are easily reachable from FancyBoxCustomUI and elsewhere
  • Passed the FancyBox instance reference to the constructor of FancyBoxCustomUI so code within FancyBoxCustomUI can access the non-static relativePath method of FancyBox
  • Adjusted method and variable references accordingly
AndreWolff

Posts: 1,289
Registered: 14-Dec-2007
Re: How to use an item declared in the main module in custom panel code?
Posted: 5 Feb 21, 09:29   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
See updated zip file.
Great! Thanks you very much David for the corrections you made, I could compile the GUI now.
davidekholm

Posts: 3,440
Registered: 18-Oct-2002
Re: How to use an item declared in the main module in custom panel code?
Posted: 5 Feb 21, 10:41   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
You're welcome
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums