Hi.
I am using netBeans 6.1 on windows XP, and when I create a java class and I create a frame inside that class? why I can not see the design of that class? I mean why I can not see the frame and also the control like buttons, text, lables and so on?

BUT when I create and new JFrame Form through visual design, then I can see the code view and also the design view.

Dani AI

Generated

Short, practical follow-ups for based on 's comment.

If a class was hand-coded you will not get the NetBeans visual editor attached automatically. The usual, safe way to get a designer-backed form without losing your work is to migrate the UI code into a designer-managed form while preserving the existing logic. Do this by extracting non-UI logic first (business rules, data manipulation, helper methods) into separate classes or plain methods so they are independent of the GUI class.

Recommended migration workflow:

  1. Create a new designer form in the same package/name-area you want to use (so package-private references still resolve).
  2. Recreate the component layout with the GUI builder and let the builder generate its code.
  3. Move event-handler bodies and UI-related calls from the old class into the new form, or better, call into the extracted helper classes so the form only glues components to logic.
  4. If you use custom Swing components, add them to the builder palette (so they render in Design view) rather than embedding raw initialization code that the builder cannot manage.

Troubleshooting and cautions:

  • Use the Projects view to make sure the form and its associated files are present; the Design tab appears only for forms the builder recognizes.
  • Avoid editing generated/guarded sections by hand; keep hand-written code in user-editable methods so it survives re-generation.
  • Keep backups of the original .java before migrating.

Longer term, favor an MVC-like separation for any GUI code you plan to maintain in a visual designer. It makes future edits, debugging, and designer use much simpler.

Recommended Answers

All 4 Replies

Hi.
I am using netBeans 6.1 on windows XP, and when I create a java class and I create a frame inside that class? why I can not see the design of that class? I mean why I can not see the frame and also the control like buttons, text, lables and so on?

BUT when I create and new JFrame Form through visual design, then I can see the code view and also the design view.

You only see the code view when you create a frame without NetBeans' help because there IS no design view. If you look in the src folder, when you use NetBeans' visual design feature, there is a file with a .form extension and a file with a .java extension. When you create your own, there is no .form file. That .form file is what allows you to see the Design view. If you delete the .form file, you won't be able to see the Design view anymore.

Thanks for the reply.
Now how I can see the design view of those file which does not have the form extension ?

Thanks for the reply.
Now how I can see the design view of those file which does not have the form extension ?

I don't think you can. If you can, I don't know how. The .form file is created when you use NetBeans' designer. If you don't use NetBeans' designer, it isn't created. I don't think you can create a .form file from a .java file, so if you want to use the Design view, I think you have to create the frame through NetBeans' designer.

Thanks for the info ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.