Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a vertical toolbar in Java?
Let us first create a toolbar −
JToolBar toolbar = new JToolBar();
Now, set the orientation to create vertical toolbar −
toolbar.setOrientation(SwingConstants.VERTICAL);
The following is an example to create a vertical toolbar in Java −
package my;
import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;
public class SwingDemo {
public static void main(String[] args) {
JFrame frame = new JFrame();
JToolBar toolbar = new JToolBar();
toolbar.setOrientation(SwingConstants.VERTICAL);
toolbar.add(new JTextArea());
toolbar.add(new JButton("Submit"));
frame.add(toolbar,BorderLayout.WEST);
frame.setTitle("Vertical ToolBar");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//frame.setLocationByPlatform(true);
frame.setSize(550, 400);
frame.setVisible(true);
}
}
Output

Advertisements