Hey all. I'm making a program which uses many buttons and a textfield. I need help and some explaining on how to organise components within a panel.
For example,using

mainPanel.add(BorderLayout.NORTH,display);
mainPanel.add(BorderLayout.CENTER,background);
mainPanel.add(BorderLayout.EAST,buttonBox);				
mainPanel.add(BorderLayout.WEST,buttonBox2 );

All components (the buttons within the background panel,the buttons within buttonbox1/2 and the display field) are "sticked". How can i add a gap between .NORTH and .CENTER?
i have tried :

mainPanel.setBorder(BorderFactory.createEmptyBorder(50,50,50,50));

but nope.
Also,The buttons in buttonboxes (box class) are Y_AXIS aligned but they also have no gap.
i tried buttonBox.createGlue(); but also nothing.
Ive been reading and messing around with gridLayouts,boxLayouts,borderFactory for a good 3 hours now...
Anyway,apart from my program,any small "guide" on how to easily play with components arrangement would be awesome.Thanks!

mainPanel.setLayout(new BorderLayout(10, 10));
mainPanel.add(display, BorderLayout.NORTH);
mainPanel.add(background, BorderLayout.CENTER);
etc

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.