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
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
Post a Comment