Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HELP NEEDED IN CODING A BEAN FOR CREATING A TOOLBAR WITH BUTTONS  RSS feed

 
kartik rathore
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI, i am creating a toolbar bean with buttons which can be used in other projects but when i load the bean in other projects, the toolbar does not display any buttons on it that i had added to it.

could any 1 help me with this please..

thanks...

code of the bean is as under ....................
........................................................

package MyButtonsBean;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;

public class Buttons extends JToolBar {
private JPanel pa;
private JToolBar t;
private JButton u;
private JButton p;
private JButton d;

public Buttons(){

// tollbar
t = new JToolBar("",JToolBar.HORIZONTAL);
t.setFocusable(false);
setVisible(true);

// button 1
setSize(24,24);
u=new javax.swing.JButton(" sjc bjascbc as cb ");
t.add(u,BoxLayout.X_AXIS);
//t.addSeparator(0);

// Button 2
p=new javax.swing.JButton(" Play or Stop ");
p.setText(" Play ");
p.setFocusable(true);
t.add(p);
p.setEnabled(true);
t.addSeparator();

// button 3

d=new javax.swing.JButton(" Down ");
d.setText(" Down");
d.setFocusable(true);
t.add(d);
t.addSeparator();
}

}
[ October 18, 2008: Message edited by: kartik rathore ]
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your class "is" a JToolBar, but in your constructor you ignore this and create a totally unrelated and never used JToolBar object, "t". Shouldn't you instead call the super constructor as the first method, get rid of "t" altogether and instead use "this" in its place?
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch

Like the rest of the Internet, we don't like reading ALL CAPITALS; please read that link.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!