Results 1 to 3 of 3
  1. #1
    SAYAN is offline Member
    Join Date
    Feb 2010
    Posts
    1
    Rep Power
    0

    Default How to open a SAVE file dialog box without using SWING or AWT

    Hi All,
    I am a new member of this forum and this is my first post.
    I want to use the "SAVE" file dialogue box (as it comes in windows asking where do you want to save a file) for saving a file. But I don't want to use AWT or SWING for this. Is there any option for this?

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    5

    Default

    in theory, it might be possible to create a kind of native component, in your native windows language of choice, such as dot net, visual C++, visual basic ? Once the file dialog is created and invoked from this native piece of code, design an interface that is suitable for use throw the Java Native Interface (JNI), where you create a java stub class that invokes this native method, atht causes the native file save dialog to be shown in your native look and feel.
    The challenges with this are after invoking the dialog, the dialog results need to be communicated back to the java process, which would then use either use a java mechanism for saving the file, or (gasp), somehow send the file contents back through the native gui stub piece of code to have it save it.

    There also might be something like this (a native screen kind of thing with a Java bindings) in some of the existing open source cross platform native widget toolkits, such as GTK+, WxWidgets, or QT., and assuming you have Java bindings to just show a file save dialog. Though using one of these would only be good to do if you are already used to working with them.

    But thats a lot of theory, I seriously doubt it is worth the trouble to go to that much effort just to have a native windows save dialog in a java application. You might as well then just write your application in some kind of native windows API code.

    Now, for Swing, there are several different look and feel options. Since Java 1.6 some of these have improved quite a bit to look closer to the native windowing system. How to Set the Look and Feel (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)

    Another option is the SWT from eclipse. That is a Java UI similar to what Swing does.

    But I suspect the motivation for using the native save dialog is to take advantage of some of the windows standard left tree menus of folders and shares or something ?

  3. #3
    stevpan is offline Member
    Join Date
    Feb 2010
    Posts
    1
    Rep Power
    0

    Default

    You can use Swing and call the native FileDialog (Windows CFileDialog or GTK Filedialog) with JNI.

    I wrote a wrapper class for Windows CFileDialog, and shared its source/dll on my Google page code. xfiledialog - Project Hosting on Google Code

    Another option is to write you program completely in SWT.

Similar Threads

  1. How invoke open dialog?
    By artemff in forum CLDC and MIDP
    Replies: 4
    Last Post: 12-27-2009, 03:18 PM
  2. save dialog problem
    By masa in forum AWT / Swing
    Replies: 2
    Last Post: 03-06-2009, 12:41 AM
  3. File dialog with save
    By manpreet in forum New To Java
    Replies: 1
    Last Post: 01-02-2009, 05:44 PM
  4. Open "Save Page As" Dialog Box
    By Anubha in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 12-12-2007, 09:27 PM
  5. Replies: 0
    Last Post: 12-06-2007, 06:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •