1
我正在制作一个IRC客户端,并且我正在使用GridBagLayout,以便在调整窗口大小时,显示消息的JTextArea也将调整大小。但是,每当我尝试和改变数字时,组件总是在屏幕的一侧(图片:http://imgur.com/BoJ84pS)。下面的代码:Java GridBagLayout - 组件脱落
setSize(750, 550);
setLocationRelativeTo(null);
contentPane = new JPanel();
contentPane.setBackground(Color.LIGHT_GRAY);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
GridBagLayout gbl_contentPane = new GridBagLayout();
gbl_contentPane.columnWidths = new int[]{15, 680, 40, 15};
gbl_contentPane.rowHeights = new int[]{15, 480, 25, 30};
gbl_contentPane.columnWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
gbl_contentPane.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
contentPane.setLayout(gbl_contentPane);
图片是有点不清楚,但的JTextArea,JButton,并JTextField中都是部分以外的窗口。顺便说一下,我正在使用windowbuilder插件来制作GUI。