this.log = tf;
// create button
JButton btn = new JButton("Push me",
new BoxIcon(Color.blue,2));
// set alternative icons
btn.setRolloverIcon(new BoxIcon(Color.cyan,3));
btn.setPressedIcon(new BoxIcon(Color.yellow,4));
// set text to left of icon
btn.setHorizontalTextPosition(JButton.LEFT);
// set border
btn.setBorder(BorderFactory.createEtchedBorder());
// set listener
btn.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
log.setText("Button was pressed");
}
});
// add button to panel
add(btn);