java - How to add a JPanel in the center of another JPanel? -


i want add jpanel map on top of jpanel worldview in it's center

example

here code:

public class worldview extends jpanel implements actionlistener{  private jpanel map;  public worldview() throws ioexception{     this.setsize(1024,768);     this.setbackground(color.black);     map = new jpanel();     this.add(map); } 

you use gridbaglayout , modify gridbagconstraints#insets or emptyborder generate whitespace around component in combination gridbaglayout or other layout borderlayout example

see how use gridbaglayout , how use borders more details


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -