Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple questions

 
J. Floyd
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. My professor directed me here to see if I could get some questions answered. I need help with Java and the program I am working on.

My program is made up of multiple classes, but some share the same panels. Is there a way I can put the panel in its own class and then call that panel to the other classes that use it?
I tried creating a class with all the variables and then making a method that returns the JPanel, however the compiler won't allow it. Are there any suggestions?

Is it possible to write to an Excel file with JDBC/OBDC? I figured out how to read from an Excel sheet, but I do not know how to make it write.

Once everything is saved to said Excel sheet, am I able to search through the values to look for a specific value? There is a section where I need to be able to search through the data and return what I'm asking for. This is one of the most crucial features to the program.

Finally, when I save the entire thing as an executable jar file, the images are not include. How do I get it to display the image?
This is the code I currently have:

but the image is not displayed when I turn it into a .jar file. It does show when I use Eclipse, however.

Thank you very much.
 
J. Floyd
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code for my first question is this:
where the entryPanel and all of its variables are declared and instantiated above in the class and constructor.
 
S. Nitesh
Ranch Hand
Posts: 36
1
Chrome Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to write to an Excel file with JDBC/OBDC? I figured out how to read from an Excel sheet, but I do not know how to make it write.

I don't know about the other questions but for creating xls you can use the poi (api for microsoft docs.) by apache.
You can refer this link for more details
http://poi.apache.org/spreadsheet/index.html

and please use meaningful subject line.
 
Campbell Ritchie
Sheriff
Posts: 48917
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nitesh Sakargayan wrote: . . . and please use meaningful subject line.
Thank you for noticing.
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
J. Floyd wrote:Finally, when I save the entire thing as an executable jar file, the images are not include. How do I get it to display the image?
This is the code I currently have:

but the image is not displayed when I turn it into a .jar file. It does show when I use Eclipse, however.

Check out Class.getResource(). This returns a URL that you can use in the ImageIcon constructor.
 
J. Floyd
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.

Sorry for the uninformative subject line, I just didn't know what to call it since there were several different topics.

I'm trying to not use any copyrighted work because I plan on protecting this program once I finish. I don't know if I'd be allowed to do so if I used JExcel or the POI. I am trying to learn XML so I can save everything as an xml and then have Excel read it.

The Class.getResource is not working. I keep getting a message saying that I cannot make a static reference to a non static method getResource(String) from the type Class.
I've tried to make a url as well, but there is something that I'm missing.



 
Campbell Ritchie
Sheriff
Posts: 48917
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would have to read the terms and conditions of use of POI to see whether you can incorporate it in your own product. It might be laborious and error-prone to write your own when there is a well-tested product already available, however.
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
J. Floyd wrote:The Class.getResource is not working. I keep getting a message saying that I cannot make a static reference to a non static method getResource(String) from the type Class.

When I said Class.getResource, that was a hint to go to the Javadoc of java.lang.Class and lookup method getResource.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
POI is under the ASL; it can be used in commercial products.

You do *not* want to duplicate this work, believe me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic