This is in my "SaveAs" Function. Dont worry about the Save Function. What I'm trying to do is set the file filter to 'nek' but I have no idea how to do this. When the file dialog appears you can save it as Anyfile, and i prefer it to be the type i want.

FileFilter is an abstract class that has no default implementation. A FileFilter, once implemented, can be set on a JFileChooser to keep unwanted files from appearing in the directory listing. For an example implementation of a simple file filter, see yourSDK/demo/jfc/FileChooserDemo/ExampleFileFilter.java. For more information and examples see How to Use File Choosers, a section in The Java Tutorial.

What I'm trying to do is set the file filter to 'nek' but I have no idea how to do this.

Theoretically, the method you're looking for is setFilenameFilter(). However, see its Javadoc comment, it has no effect on Windows. So the AWT file dialog can't do what you want to achieve. Either use Swing or you have to create your own implementation of a FileDialog.T

Btw usually you create the dialog once at the beginning and show each time you need it. This way it's more responsive, generates less garbage and as a side effect you stay in the last choosen directory (that's expected behaviour btw).

So what do i do then? Im still new to java to do some of the stuff. Does anyone know how you do it in windows?

Use Swing. Then you don't have to worry about AWT short commings.

Or check out SWT - an alternative UI framework created to support the Eclipse platform which of course works fine standalone, too. However, SWT is different to Swing and AWT, having its own merits and problems.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org