Rounded borders on a JPanel

淺唱寂寞╮ 提交于 2019-12-10 09:47:35

问题


What I've got here is a JPanel with a rounded border that is set up as such:

panel.setBorder(new LineBorder(PanelColor, 5, true));

The problem is, in each of the corners there are 2 diagonal opaque lines going from the outer corner to the inner corner that is the length of the border. Whatever is behind the border shows through. Is there any way to get rid of these lines and make the entire border one solid color? Thanks!

I'd attach a picture but I don't have enough rep to do so :P


回答1:


Maybe here is a way to paint RoundedLineBorder; please be careful with constants for nice output to the GUI.




回答2:


Your problem may be that the background panel is white and your foreground panel is PanelColor and since you are rounding out the edges you are seeing the white background behind your foreground panel.



来源:https://stackoverflow.com/questions/6821789/rounded-borders-on-a-jpanel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!