This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 557
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.


Learning Java using Eclipse on OpenSUSE 11.2
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: 557
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: 4523
    
    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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: problem in swing tool bar
 
Similar Threads
How to create 2 toolbar consecutive on a JFrame???
Adding Component to the right in JToolBar
Accesing system clipboard in Applet
How can I find my images??
WhenI try to run this applet it gives an error??? why??need help!