aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes problem in swing tool bar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "problem in swing tool bar" Watch "problem in swing tool bar" New topic
Author

problem in swing tool bar

Kasun Wixkramanayake
Ranch Hand

Joined: Feb 09, 2010
Posts: 74

i used above code to make a horizontal toolbar in my gui.but id dosent work properly.(i used netbeans to run above code )
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 561
You have to explain what you mean by "doesn't work properly." I notice that you haven't added any ActionListeners to your buttons. Perhaps this tutorial will help.


Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Kasun Wixkramanayake
Ranch Hand

Joined: Feb 09, 2010
Posts: 74
sorry for the mistake.my toolbar dosenot appear in jframe. that is my problem
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 561
Can you expand the code you're showing us a bit to include the JFrame construction, including the addition of the JToolBar?
Kasun Wixkramanayake
Ranch Hand

Joined: Feb 09, 2010
Posts: 74
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

Your contentPane has a GroupLayout, set in initComponents(). You can't just add a toolbar or any other component without specifying its group.

This is why I repeatedly point out that the NetBeans visual designer isn't a beginners' tool. Go through the Swing tutorials and learn how to write Swing code and how to layout your components using layout manager(s) that are easier to understand than GroupLayout. While you're there. go through the section on How to Use Toolbars.


luck, db
There are no new questions, but there may be new answers.
Kasun Wixkramanayake
Ranch Hand

Joined: Feb 09, 2010
Posts: 74
what happen if i add this tool bar into jpanel.will it give any errors
A Thakur
Greenhorn

Joined: Apr 06, 2010
Posts: 20
You have to add JToolBar to JPanel. It should not give you any errors

For example:



See if it helps.

Thanks.


SCJP 5.0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in swing tool bar