Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How to open Swing components client side

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've built a java application that allows users to save a file to their desktop using a JFileChooser in a JFrame. I've got it deployed to a Tomcat on a virtual server running CentOS (hence no monitor) so of course I'm getting a java.awt.HeadlessException when I call super(). If I run tomcat through a shell via ssh, however, it opens the file chooser on my machine which is heartening, but pointless as it doesn't matter where the application is being viewed from. How do I set this up to open swing components client side? Or, heaven forbid, must I resort to an applet?
 
Matthew Snow
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I forgot about this post. Here is what I ended up doing. I basically ditched the whole swing thing and just sent a byte stream to the HttpServletResponse object, which a browser understands as a file download. Here is the code (java 5 compliant)



The method fileEntiresToByteArray() simply parses the List object and appends the data to a String object. It then returns str.getBytes().
 
On my planet I'm considered quite beautiful. Thanks to the poetry in this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic