0

I'm total newbie in Swing. I created new project and there I created new JFrame Form. Into this file I copied some tutorial code of GUI(Chess board). Everything works, i can build and run. The problem is when I try to left-click on the name of the file and choose Editors->Design it shows me empty Frame. Is there any way how to fix this(it's more intuitive to operate with design view then in code)

P. Barbra
  • 21
  • 1
  • 8
  • 3
    *"(it's more intuitive to operate with design view then in code)"* But unless you understand how to code by hand, the designers will produce rubbish, fragile code that is harder to maintain. *"when I try to left-click on the name of the file and choose Editors->Design it shows me empty Frame."* That reminds me. And you get locked into using that one IDE, because, no, regular source cannot be imported and used in a GUI designer, and source exported from one GUI designer cannot be used in another GUI designer. .. – Andrew Thompson Apr 27 '16 at 00:39
  • 1
    .. (The GUI designers usually use some form of XML behind the scenes to describe the GUI, and there is no standardization of the XML.) – Andrew Thompson Apr 27 '16 at 00:39
  • 1
    *"GUI(Chess board)."* See also [Making a robust, resizable Swing Chess GUI](http://stackoverflow.com/q/21142686/418556). – Andrew Thompson Apr 27 '16 at 00:41
  • @AndrewThompson Oh, ok. Also there is no way to get design view from code. It's only possible to get code from my drag-and-dropped design, right? – P. Barbra Apr 27 '16 at 00:56
  • *"It's only possible to get code from my drag-and-dropped design, right?"* If you'd call that mess 'code'. Besides not being able to import into other GUI designers, they will usually use `GroupLayout` that is considered to be very hard to write (or change) by manually writing code. So given it cannot be imported into another GUI designer or easily changed by hand, I cannot see the point to exporting it at all (unless it's for someone using the same IDE & the GUI designer). – Andrew Thompson Apr 27 '16 at 01:00
  • 2
    Netbeans doesn't work like this, it generates code that it can read, it won't generate a UI from code you've written – MadProgrammer Apr 27 '16 at 02:50

1 Answers1

2

I understand what you mean. Besides the (FormName).java file, you also need the original (FormName).form file to be copied into the src folder. Without it, there is no way for the IDE to translate the code to the design enviroment.

arlokan
  • 88
  • 1
  • 9