How do I disable a JPanel so that it can't change size in Java
问题 I have several JPanels in a layout and whenever I change the size of the JFrame manually with my mouse, it stretches the JPanels and makes it look messy. Is there a way to disable this? 回答1: JPanel is not resizable by the user. If you are referring to JFrame, you can use yourFrame.setResizable(false); 回答2: It's all about the LayoutManager you are using. Some LayoutManagers like BorderLayout always give extra space to children added in the center position. However, north, south, east, and west