• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in swing tool bar

 
Kasun Wixkramanayake
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kasun Wixkramanayake
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry for the mistake.my toolbar dosenot appear in jframe. that is my problem
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kasun Wixkramanayake
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what happen if i add this tool bar into jpanel.will it give any errors
 
A Thakur
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to add JToolBar to JPanel. It should not give you any errors

For example:



See if it helps.

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic