aspose file tools*
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing application using netBeans IDE" Watch "Swing application using netBeans IDE" New topic
Author

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
Hi,

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.setBorder(BorderFactory.createLineBorder(Color.Blue));
label.setPrefferedSize(new Dimension(60,30));

panel.add(label);


--Syam.Sathyan


Syam.Sathyan.George
(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
Greenhorn

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.
Answer:
Create jframe in netbeans.
add panel to frame.
then right click on panel & go set layout.
select Grid layout.
now

Jlabel l=new Jlabel("Hiiii");
jpanel.add(l);
jpanel.revalidate();

It's work for me.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Swing application using netBeans IDE