Toolbar with 4 buttons

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

public class ToolbarDemo1 extends JFrame {
	JPanel p1;
	JToolBar tb1, tb2;
	JButton b1[] = new JButton[5];
	JButton b2[] = new JButton[5];

	public ToolbarDemo1() {
		super("Toolbar demo");
		setSize(500, 600);
		getContentPane().add(p1 = new JPanel());
		tb1 = new JToolBar();
		tb1.add(b1[0] = new JButton("First"));
		tb1.add(b1[1] = new JButton("Next"));
		tb1.add(b1[2] = new JButton("Previous"));
		tb1.add(b1[3] = new JButton("last"));
		tb1.setAlignmentX(100);
		p1.add(tb1);
		tb2 = new JToolBar();

		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setVisible(true);

	}

	public static void main(String[] args) {
		new ToolbarDemo1();

	}

}

Download

Toolbar in Swing

Toolbar with buttons


Write your Comment

Name :
Email Id : [ We will not publish your email id ]
Your Comment : [ Maximum 200 chars ]
Enter Security code