Question

i am trying to add Separate between the JMenuBar and JToolBar because it's coming like their are no space between JMenuBar and JToolBar for example can i make JToolBar bold or something

JPanel addTable = new JPanel(new BorderLayout());
addTable.add(table,BorderLayout.NORTH);
addTable.add(toolbar, BorderLayout.NORTH);

Container cp=getContentPane();
cp.add(addTable);

enter image description here

Was it helpful?

Solution

You can use a MatteBorder for the JToolBar and just set the top edge

JToolBar toolBar = new JToolBar("ToolBar");
MatteBorder matteBorder = new MatteBorder(1, 0, 0, 0, Color.BLACK);
toolBar.setBorder(matteBorder);

This will give you a line on top of the tool bar, one pixel color black

enter image description here

Disregard the complete image. Its just some code I had handy with a menu bar in it.

Notice the line at the top of the toolbar to give more distinction in separation. You can play around with the pixel thickness and color. If you want it a little more subtle, tou can use a color like light_gray or gray. Your choice

See MatteBorder javadoc

OTHER TIPS

also there are some tutorial for JPanel Border here Border tutorial

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top