Hi..

I am working with netbeans for making my desktop application (swings)..

I want to edit my frame (like setting icon to the Jframe , etc ) but i couldn't able to do so. This auto-generated code in netbeans really sucks. I cant see where the jframe object is created and so on. I cant edit the code.. please can anyone tell me how to make changes to jframe manually .

Netbeans really sucks for swings..

Maybe you would be happier with Eclipse and WindowBuilder? That combo gives you full two-way editing/updating of code or GUI design. (It's what I use)

I'm assuming you're using the latest Version of Netbeans and you'd have used one the Swing GUI forms for the current file for your project

Other than the Source Code being next to the Design tab where you could simple Drag and Drop any Swing Components you could add and customize any events to it by right clicking the Jframe from the design or from the Navigator.

Also have you happen to do a Web search on how to do it with Netbeans or reading tutorials for it?

I've been using Netbeans A lot for Swings and it made my life A lot easier with the auto-generated code for my design

The only downside I see on using Netbeans is you wouldn't be able to run the code on all platforms since it uses Ant build for the generated Code where I'd have to edit it myself

When i create a window in netbeans, it actually creates a JPanel but not JFrame.
So i am not able to set icon to the JPanel as we can only set icon to the jframe. How can i get the jframe object instead of the jpanel object. And also i cannot place the components as my wish using setBounds() method because the netbeans uses some default layout that can only understood by alien :)

When i create a window in netbeans, it actually creates a JPanel but not JFrame.

huh.. A JPanel instead of a JFrame?
Are you sure you used the Java Swing -> JFrame option when you created a new Java File

Also you can add Jpanel into JFrame..and add all components in Jpanel..
It is directly provided in netbeans..

you can use setBounds() method as given below..

Import the Java Swing package in order to have access to the setBounds method. For example, import the package at the start of your program using the code:
import javax.swing.

Set the layout manager to null to eliminate the use of Java's default layout manager, border layout. After you have created a container for the JButton component call the setLayout method for that container. For example, if the container's name is "pane," the code becomes:
pane.setLayout(null);

Create a JButton. For example, to create a JButton named "button1" and labeled "Button," the code becomes:
JButton button1 = new JButton("Button");

Add the JButton to the container using the "add" method. The code adding the example button to the example pane becomes:
pane.add(button1);

Call the setBounds method on the JButton containing four parameters: the leftmost pixel position, the topmost pixel position, the width of the JButton in pixels and the height of the JButton in pixels. For example, to set the bounds of a JButton that you wish to appear 250 pixels from the left of the frame, a top located 300 pixels above the lower border, 300 pixels wide and 150 pixels high use the code:
button1.setBounds(250, 300, 300, 150);

Yes, you can use a null layout manager and position/size all your components with setBounds, but that's taking you in a very bad direction.
The reason for layout managers is to keep Java GUIs portable across different computers and operating systems. If you have hard-coded pixel sizes then move the app to a high0-resolution display all the components will be too small and none of the text will fit. Similarly if you move it from Windows to a Linux variant the system font will be completely different and again all yout text wil the messed up. (You also have a big problem if the user wants to re-size or maximise the window.)

Layout mangers were invented to allow the GUI to automatically resize based on the characteristics of the machine where it is running, and to deal with the user re-sizing the window in a sensible way. Yes, some of them are very complex/powerful/difficult to understand, but some are very easy and simple to use. Please do yourself a favour and spend a couple of minutes reading http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html

This article has been dead for over six months. Start a new discussion instead.