I'm using GridBagLayout and JPanel 2 seems to always be in the center of the JPanel 1. JPanel 2 gets dinamically adjusted in height throughout the program, so I can't stick it to the top using gbc.insets.top = -15;
(gbc = GridBagConstraints) for example. I've tried gbc.anchor = GridBagConstraints.PAGE_START;
or gbc.gridheight = 3;
but they don't seem to do what I'm looking for.
假设JPanel 1和JFrame保持相同的大小(JFrame不可调整大小),我如何才能使JPanel 2始终位于顶部,而又没有这个间隙呢?