JDK-5098560 : Introduce Toolbar containers
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-09-08
  • Updated: 2004-09-16
  • Resolved: 2004-09-16
Related Reports
Duplicate :  
Description

Name: rmT116609			Date: 09/08/2004


A DESCRIPTION OF THE REQUEST :
It woulb be great if Swing can offer some kinds of toolbar containers which enable these features:
1. Toolbar container can be contain several toolbars
2. The toolbars can be smoothly moved in the toolbar container
3. The container support automatic wrapping-in feature as the Windows forms in .Net

JUSTIFICATION :
Implementing this feature will help better application with great GUI.

ACTUAL -
There can be only one toolbar in the application, the toolbar can not be divided into several pieces

---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.Container;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JToolBar;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

public class ToolbarHandling {
    
    static {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public ToolbarHandling() {
        final JFrame frame = new JFrame("Test (Simple toolbar)");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        JToolBar toolbar1 = new JToolBar();
        toolbar1.add(new JButton("-- toolbar one ---"));
        
        JToolBar toolbar2 = new JToolBar();
        toolbar2.add(new JButton("-- toolbar two ---"));
        
        Container contentPane = frame.getContentPane();
        contentPane.add(toolbar1, BorderLayout.NORTH);
        contentPane.add(toolbar2, BorderLayout.EAST);
        
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                frame.pack();
                frame.setSize(600, 200);
                frame.show();
            }
        });
    }

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

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Write your own component
(Incident Review ID: 302285) 
======================================================================