Java Swing layout manager circular reference being set twice
问题 Can anybody explain why circular reference is being set twice in the followig code? //declare panel this.cntnrPnl = new JPanel(); //define layout manager for the panel - but why circ ref? this.cntnrPnl.setLayout(new BoxLayout(this.cntnrPnl, BoxLayout.Y_AXIS)); Why is it necessary to link the BoxLayout back to the JPanel container explicitly instead of JPanel.setLayout doing the setting itself behind the scene and using a setter from BoxLayout for code compactness? E.g.: this.cntnrPnl