I have created a fairly substantial Java GUI application with many form windows where the settings are locked up in .form files. I am wondering is there any way to convert or refactor these .form files into real Java source code that I can modify?
The GUI was created using Netbeans 6.5.
My understanding is that the ".form" files are only used by the Netbeans GUI builder to keep track of where the GUI components are. When you add components in the design view, Netbeans automatically updates the actual source (.java) files. You can actually modify these .java files directly to, say, change the label on a button, but if you do it within Netbeans, it will use the .form files to automatically regenerate the source files, destroying your manual changes.
In my experience, once you make the decision to modify the .java files manually, the .form files become out of sync and you will no longer be able to use the Netbeans GUI builder properly.
kazanaki is right, the java files that are generated can be modified but the resulting .java files are notoriously messy, large and hard to interpret. Also, you cannot change some things (as noted in the comments in the generated .java file) without rendering matisse useless because it expects the file to have things in a certain way. That being said, if you are careful not to step on Matisse's toes you can code away and it will not touch your code which is nice.
Outlaw is right too, if you change anything that is already in Matisse's perview it will be overwritten. Any changes that you make outside of matisse must be outside of any element that is covered by the xml that matisse uses to generate the code.
I have tried this kind of thing before with limited success and eventually just rewrote the interface to avoid these maddening headaches.
I can edit the source, I discovered the solution. THe problem was that I was using the "AbsoluteLayout" in the GUI builder. Netbeans was creating some hidden AbsoluteLayout class that was inside the .form files. IF I deleted the .form files the project would no longer build. The solution was to change the form to be of "FreeForm" layout and then I could delete the .form files and remove the GUI builder comments.
Thank you for the help guys, I give you both +1.
Related
So I have made a simple game using Java. I have my Jar file and inside it I am keeping my pictures. It's like a lot of pictures going on there. Like 140+ pictures at around 9 MB (mostly icons) (Not worried about efficiency, game already runs pretty smoothly). Now I wrapped my jar file into an .exe and then used Inno Setup to make a setup file. The thing is I am creating a folder in Program Files that only has a the application.exe file and the uninstallation file. This looks a bit vague to me and unprofessional. Though I've seen great games having all of their icons outside of the executable of course, just wondering would it be a good practice to keep the images inside or out ?
Suggestions are welcomed :D
I prefer to keep images and other resources inside the JAR file. You don't want the user to change any of them, same as for the program classes. So I don't see why you should have a different storage for images compared to classes.
The most robust and simple (and that should be the meaning of "professional") setup is to have the whole program with all its prerequisites in just one file - either it's there and works, or it's missing, and you'll see that immediately. No need to check for existence and accessibility of dozens of subdirectories and files.
And as you're asking the question, you surely managed to read the images from the classpath, thus allowing to store them together with the class files, e.g. in a JAR.
Regarding wrapping in an EXE, that shouldn't make a difference: if the ClassLoader finds the classes, it'll surely find the images the same way. And even Ahead-Of-Time-Compilers support getResourceAsStream() (we've done that with Excelsior Jet).
I am creating my own custom IDE for my programming language, and I came upon a problem. In any IDE, you always want to be able to import images, other projects, and other files. Therefore, I would definitely love to have that in my IDE. I am using JavaFX for my GUI. I have already created a FileChooser, and a user can successfully choose a File they want to import into my IDE.
Here's My Question
When a user selects a File, should I use the File.copy() method to copy the File over to the IDE, or should I copy all the bytes from the File onto a resources file in my IDE? Copying the File directly would lead me to have a Resources folder attached to the Project, but I do not know if that would be the most optimal way of importing Files into my IDE. Is there a preferred way of importing and saving Files in Java? What would be the best way for me to do it in this case?
Thanks in advance!
Ideally user should have have both options and IDEs tend to support both ways.
Practically, don't get stack on this. Implement either one, and move one with other tasks to have a working prototype earlier.
It is more important to check if your language has design flaws before you devote too much time decorating gui.
I am curious in knowing how a file could have different views or be associated to different files in eclipse.
What I basically mean is how eclipse is providing associated files/views as tabs at the bottom of a file while in editing mode. (I am attaching an image for understanding purposes)
What's the place to look into in case that I want to implement something like this for my files.
I have a JTextArea, and I have this being populated with a chosen .java file, the problem is that the file is appearing as just normal text. I would like to add some pretty print so that the user will be able to see the file as if the file was open in eclipse (keywords different color, comments will be in grey... etc)
I have not been able to find any good examples online for how to do this. what would be the best way to do this?
EDIT:
I got this to finally work, i added the JSyntaxPane jar file to my classpath (jsyntaxpane-0.9.5-b29.jar to be exact) then i added the following two lines of code to get it working for my JEditorPane.
jsyntaxpane.DefaultSyntaxKit.initKit();
JEditorPane.setContentType("text/java");
This can also be used on the following languages: JavaScript, Properties, Groovy, C, C++, XML, SQL, Ruby and Python... just by simply changing text/java to text/LANGUAGE_YOU_WANT in the above code
JTextArea can only display plain text (like notepad in Windows). If you want to show pretty printed source code with colors, you need JEditorPane, which allows you to display HTML.
Now you can either generate HTML manually with syntax-highlighted Java source code or use some library.
See also
Where can I find a syntax highlighting library for Java?
JEdit-Syntax has a JEditTextArea class that will do syntax highlighting. This project was spun off to package some subcomponents of the JEdit project.
Motivation
I have written an eclipse plugin that shows me a list of all files and folders with unreviewed content. When selecting a folder, I want an editor to open showing all files and subfolders that this folder contains. It has to work for versioned items, too. So I have to create the content of the editor within my plugin (no backing IResource).
What I currently have
Right now I'm opening a RemoteFileEditorInput for a versioned file (subclipse) or I'm using IWorkbenchPage.openEditor() for a FileEditorInput.
Question
What's an easy way to visualize dynamic content (directory listing) inside of an text editor?
EDIT 2010-04-13:
More Context
I want to be able to create some code review comments on a directory listing. For this I want to be able to open a diff viewer to see which elements were removed or added between two revisions of the directory.
I'd like to enter a comment for a directory the same way I do for a text file. That's why I try to display the directory content as a text file - I've already implemented the mechanisms for commenting a text file.
I call the content of the directory editor "dynamic", because it's not really backed by an existing directory in the filesystem. For older versions of a directory I will create the editor content within my program code.
I'm afraid I don't totally understand your question (and I lack the rep to comment on it).
Is this right?: You want to be able to open one of three editors in support of your goal:
An editor for unversioned files (you say you have this)
An editor for versioned files (you say you have this)
An editor for directories (this is what you need?)
What does the user do here? What does it look like?
I'm confused by "What's an easy way to visualize dynamic content (directory listing) inside of an text editor?"
Knowing that I probably completely miss your point, I would note that your editor can contain whatever controls you want it to (cf. some of the "forms" editors in PDE, like for editing a plug-in manifest) - you'd probably extend EditorPart, maybe create a ManagedForm in your createPartControl(), create a ListViewer, TableViewer, or TreeViewer in there, give it an appropriate content provider, and give it an appropriate label provider.
I'm also confused by "What's an easy way to visualize dynamic content (directory listing) inside of an text editor?"
I can only assume that you want to somehow poll or listen to some events and tell your viewer to update() or refresh().
Finally I would question whether the directory listing really belongs in an editor . . . most navigation happens in views. Will the user actually be performing edits to the directory somehow, and possibly "saving" them at some later time?
I hope this helps us all narrow down into whatever will help you.