パネルを作成し、そのためにグリッドレイアウトを使用しました。
public pnlFriends() { initComponents(); this.setLayout(new GridLayout(10,1)); // showFriends(); } private void formComponentShown(java.awt.event.ComponentEvent evt) { showFriends(); System.out.print("comp"); } private void showFriends() { //Integer id = NewMain.network.getEdges().get(Main.uuid).getDegree(); for(int i = 0;i < 10 ;i++) { String name = "as"; String occupation ="adf"; String place = "asdf"; Integer connections = 5; this.add(displayMiniProfile(name,occupation,place,connections)); } }
ここでdisplayMiniProfile
、JPanelを返します。
これで、親JPanelのコンストラクターでこの関数を呼び出すと、この関数が機能し、MiniProfileJPanelを追加できます。
しかし、componentshown
イベントの応答でこの関数を呼び出すと、何も表示されません。
なぜ ?
そして、どうすれば同じことを達成できますか?