File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Swing application using netBeans IDE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing application using netBeans IDE" Watch "Swing application using netBeans IDE" New topic

Swing application using netBeans IDE

Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
I have a swing application developed using text editor. As I found it bit difficult to play around with layout manager, I thought of giving it a try using netbeans and slowly converting my original application. I have few buttons and JPanel. I am trying to add dynamically generated components like Jlabel and Jcheck box into my JPanel. Everything works perfectly fine without any error but I am not seeing any dynamically generated components inside my JPanel. What might be the problem? Thanks.
Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
I tried a small example as below. I created JPanel inside the frame using palette. And I added the code below into actionPerformed of a button.

Nothing is visible inside the JPanel (jPanel1). But when I count the number of components inside that JPanel, I am getting the correct number of components generated inside that JPanel. Why the dynamically generated components are invisible? Thanks.
Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
This is a small example. The label is not visible in the JPanel. Since I used netbeans I am posting the entire code generated. Please let me know why the component JLabel is not visible inside the panel. Still I couldn't figure it out.

[ April 08, 2008: Message edited by: Gopu Akraju ]
Syam Sathyan George
Ranch Hand

Joined: Apr 26, 2006
Posts: 64

Add the following code to locate your component in case its not drawn in visible are due to size issues. Trust me Netbeans generated Group Layouts can be tricky in space determination of components before laying them out!!

JLabel label =new JLabel("Hi");
label.setPrefferedSize(new Dimension(60,30));



(My boss is a Jewish carpenter)
Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
I tried as mentioned by Syam. But still it is not visible.

Shashika Thiran

Joined: Jan 22, 2009
Posts: 24
I,m not expert in java.I have same problem you mention.Accidently i found solution for that question.
Create jframe in netbeans.
add panel to frame.
then right click on panel & go set layout.
select Grid layout.

Jlabel l=new Jlabel("Hiiii");

It's work for me.
I agree. Here's the link:
subject: Swing application using netBeans IDE
It's not a secret anymore!