tags:

views:

52

answers:

1

i have .java file. i need to generate .form file using the java file. when i write a java file then automatically .form file should be created. by using java swings how can we create .form file

+1  A: 

Your question is as vagues as they get, but usually it's the other way around - you generated java code from a form file created by a GUI designer such as NetBeans Matisse, Eclipse Jigloo or IntelliJ IDEA Forms designer. Although they all use the .forms extension the internal format differs wildly on different IDEs - it's generally some xml markup, that's later used to generated to Java code related to the GUI layout, so you wouldn't have to code it yourself. I find it hard to believe you want to generate form files from an existing layout...

As far as I know Sun Java Studio Enterprise is based on NetBeans, so probably your GUI designer is Matisse. There is no way to regenerate the form from they Java code(at least nothing short of you writing some tool to parse the code in the initComponents() method, which will be a start, but not enough to get everything back). As gnoupi pointed in the other question you posted - your best bet would be to read the existing source and restore the form based on it. All this of course assumes that you're not using version control and there is not way to restore the project's missing form file from there.

Bozhidar Batsov
It's probably because the form file got deleted in the meantime, and now the user needs to change the layout. Without the form file, it's nearly impossible (especially if using a GroupLayout).
Gnoupi
Besides, you are not answering the question, so this should remain a comment.
Gnoupi
@Gnoupi - this is probably the best possible answer for this question.
Andreas_D
I'm a professional Swing developer - I'm fairly aware what is possible and what is not is Swing ;-) If he deleted the form and doesn't use a VCS it's fairly hard to recover. Tools like IntelliJ allow you to capture the layout a Swing form at runtime and generate a IntelliJ designer specific form it, but without any more info about the particular IDE I cannot say more. I use MigLayout ever for the most complex layouts, few real swing devs would opt for a GUI designer at all - it limits you too much and generates a lot of ugly code...
Bozhidar Batsov
im using java studio enterprise 8 IDE. can i generate using this IDE??
charan
"I'm a professional Swing developer", well, good for you, so am I (though I have experience only with Matisse, good to know about InelliJ's capacity to create a form from an existing layout). What you wrote as comment now is a possible answer, but not what you actually answered. You were only explaining forms, and questioning the user's need with "I find it hard to believe".
Gnoupi
Didn't mean it in a offensive way, mate. I was irritated partly by the behavior of the user that asked the question two times instead of providing details here. I've updated my answer, featuring your answer from the other question.
Bozhidar Batsov