Orloffyeah
Orloffyeah

Reputation: 1

Adding two JComponents to the North of a JFrame BorderLayout

I have a paint-like project, in which I recently added a JSpinner, but after researching how to add it to the JFrame, it ends up looking like this:

but I would like it to look like this:

how would I accomplish this? Thanks in advance.

P.D: The code used to create the current project is this:

public View( final String title ){
        super( title );
    }

    public void init()
    {
        canvas = new Canvas();
        menuManager = new MenuManager();
        toolBarManager = new ToolBarManager( JToolBar.VERTICAL );
        spinnerManager = new SpinnerManager();

        JPanel subPanel = new JPanel( new FlowLayout() );

        subPanel.add( menuManager );
        subPanel.add( spinnerManager );

        add( BorderLayout.CENTER, canvas );
        add( BorderLayout.NORTH, menuManager);
        add( BorderLayout.EAST, toolBarManager );

        setDefaultCloseOperation( EXIT_ON_CLOSE );

        App.getInstance().addDrawingListener( this );

        canvas.init();
    }

Upvotes: 0

Views: 481

Answers (1)

Hovercraft Full Of Eels
Hovercraft Full Of Eels

Reputation: 285403

Simply give the top JPanel an appropriate FlowLayout: new FlowLayout(FlowLayout.LEADING))

Upvotes: 1

Related Questions