• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to integrate existing classes to Swing project

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have some Java classes that I have successfully tested using Windows console. Now I need to develop a user interface to use such classes which can be graphical or text based and I would like to try Java Swing.
How do I integrate the classes I already have into a Swing project in order to, for example, instantiate them when a button is clicked and call its methods?
I tried to copy and paste my classes in my Swing project but I get an exception when I run it. The exception is like this:

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: csce315Test.dbEngine
at csce315Test.DBMS_Test_GUI.btnConvertActionPerformed(DBMS_Test_GUI.java:85)
at csce315Test.DBMS_Test_GUI.access$000(DBMS_Test_GUI.java:15)

Line 85 is precisely where I instantiate my class.

I have Java Swing installed in a Windows 10 PC. JDK is also installed of course.

Respectfully,
Jorge Maldonado
 
Bartender
Posts: 732
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Line 85 is precisely where I instantiate my class.


Well, why not show us that line, and also the constructor of that class?
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Uncompilable source code"

That implies you are trying to execute code that doesn't actually compile.
 
Jorge Maldonado
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Tolls wrote:"Uncompilable source code"

That implies you are trying to execute code that doesn't actually compile.



The classes I am using do compile. I have already compiled them with "javac" and they run successfully in Windows console. I tested my classes directly in a Windows Console (instantiate them and call their methods). The problem is when I integrate them into Swing.

Regards.
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you running your new code?

How are you integrating your current application into Swing?

And, as Fred has asked, what is on line 85? Or that DBMS_Test_GUI class in general?
 
Jorge Maldonado
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Tolls wrote:How are you running your new code?

How are you integrating your current application into Swing?

And, as Fred has asked, what is on line 85? Or that DBMS_Test_GUI class in general?



I just performed a second installation of NetBeans in another PC with Windows 8.1.
I created a new Swing project and a simple JFrame form with only a button.
I also copied my classes to the Swing project.
I wrote code for the button in the JFrame form to instantiate my 3 classes, called some methods, and it worked perfectly.
I do not know why it is working now. The only difference I see is that one PC has Windows 10 and the other Windows 8.1.
Well, there is another difference. In my Windows 10 PC I ran my JFrame form several times before copying my classes. In my Windows 8.1 PC, I copied my classes and then ran the Swing project for the first time.
Is there anything special in how I ran the project?

Best regards.
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No idea.
We never saw the code.

That error comes from attempting to run code that doesn't compile.
I'm not sure about Netbeans quirks, but it's possible you didn't save a fix and ran code that was incorrect maybe? I'm fishing.
 
Jorge Maldonado
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Tolls wrote:No idea.
We never saw the code.

That error comes from attempting to run code that doesn't compile.
I'm not sure about Netbeans quirks, but it's possible you didn't save a fix and ran code that was incorrect maybe? I'm fishing.



I have not made any changes to my classes for the last week or so.
I have searched in Google for the exception and I have found answers like "delete everything in .netbeans/6.9/var/cache/index/. change 6.9 with your version" (I have seen several posts in Google talking about the data cached by NetBeans) or "clean and build project".
I will try "Run / Clean and Build Project" later when I get home. I do not know where to find the NetBeans "cached" data in my Windows 10 PC.

I will be back to the forum later. In the meantime, I will very much appreciate any additional feedback.
I really appreciate your very very fast responses.

Thank you.
 
Fred Kleinschmidt
Bartender
Posts: 732
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I will very much appreciate any additional feedback.


Ok: Whenever you ask a question, show the relevant code!
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jorge Maldonado wrote:I have not made any changes to my classes for the last week or so.



Except you had made changes when you posted the original problem.


I tried to copy and paste my classes in my Swing project but I get an exception when I run it. The exception is like this:
...
Line 85 is precisely where I instantiate my class.



That is a code change.
That is the new code that was causing issues (potentially).

But, as Fred says, when you have an issue with code it really does help to show the code causing the problem.
 
Did you miss me? Did you miss this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic