Shows a vertical toolbar. : Toolbar « Swing JFC « Java






Shows a vertical toolbar.

    

import java.awt.BorderLayout;

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

public class VerticalToolbar {
  public static void main(String[] args) {
    JToolBar toolbar = new JToolBar(JToolBar.VERTICAL);

    JButton selectb = new JButton(new ImageIcon("select.gif"));
    JButton freehandb = new JButton(new ImageIcon("freehand.gif"));
    JButton shapeedb = new JButton(new ImageIcon("shapeed.gif"));
    JButton penb = new JButton(new ImageIcon("pen.gif"));

    toolbar.add(selectb);
    toolbar.add(freehandb);
    toolbar.add(shapeedb);
    toolbar.add(penb);

    JFrame f = new JFrame();
    f.add(toolbar, BorderLayout.WEST);

    f.setSize(250, 350);
    f.setLocationRelativeTo(null);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
  }
}

   
    
    
    
  








Related examples in the same category

1.Create two toolbars
2.A simple frame containing a toolbar made up of several ButtonsA simple frame containing a toolbar made up of several Buttons
3.An example of JToolBarAn example of JToolBar
4.Toolbar SampleToolbar Sample
5.JToolBar DemoJToolBar Demo
6.Swing ToolBar DemoSwing ToolBar Demo
7.ToolBar Demo 2ToolBar Demo 2
8.Toolbar and menubarToolbar and menubar
9.Simple toolbarSimple toolbar
10.Working with a ToolbarWorking with a Toolbar
11.Get ToolBar PropertiesGet ToolBar Properties
12.If the toolbar is to be floatable, it must be added to a container with a BorderLayout.
13.Highlighting Buttons in a JToolbar Container While Under the Cursor
14.JToolbar: Toolbars provide a quick access to the most frequently used commands.JToolbar: Toolbars provide a quick access to the most frequently used commands.
15.Preventing a JToolbar Container from Floating
16.Determining When a Floatable JToolBar Container Changes Orientation
17.Create a vertical toolbar
18.Add various buttons to the toolbar
19.ToolBar UI SampleToolBar UI Sample
20.ToolBar button
21.This class represents a separator for the toolbar buttons.
22.Buttons used in toolbars.
23.A frame with a toolbar and menu for color changesA frame with a toolbar and menu for color changes