Use of the "Java" JToolBar class

Source: Internet
Author: User

1. Introduction

Under most look and feels, the user can drag the toolbar away from the original window component (unless the Floatable property is set to false). To be able to implement the drag effect normally, an instance of the class is suggested to be added to four edges in the BorderLayout layout-managed container.

2. Code
 PackageCn.test2;Importjava.awt.BorderLayout;ImportJava.awt.Color;Importjava.awt.Dimension;ImportJavax.swing.JButton;ImportJavax.swing.JFrame;ImportJavax.swing.JPanel;ImportJavax.swing.JToolBar; Public classjtoolbartest {JFrame JF=NewJFrame ("JToolBar test"); JToolBar Toolbar=NewJToolBar ();  Public voidinit () {JButton tool1=NewJButton ("Tool One"); JButton tool2=NewJButton ("Tool Two"); JButton tool3=NewJButton ("Tool three");        Toolbar.add (TOOL1);        Toolbar.add (tool2);                Toolbar.add (TOOL3);        Jf.add (toolbar,borderlayout.west); JPanel Panel=NewJPanel ();        Panel.setbackground (color.red);                Jf.add (panel); Jf.setpreferredsize (NewDimension (500, 500));        Jf.pack ();        Jf.setdefaultcloseoperation (Jframe.exit_on_close); Jf.setvisible (true); }     Public Static voidMain (string[] args) {Newjtoolbartest (). Init (); }}

:

Use of the "Java" JToolBar class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.