に問題がありJDesktopPane
、追加JInternalFrame
してから に表示しJFrame
ます。
JInternalFrame
問題は、実行時に別のものを追加しようとしたときです。
同じ方法を使用して同じものを追加しJInternalFrame
ますが、そのdosntが表示されます。
public class Desktop extends JDesktopPane {
(...)
public void addJInternalFrameBox(JInternalFrameBox jifb) {
this.add(jifb, desktop.CENTER_ALIGNMENT);
this.repaint();
this.validate();
}
}
JInternalFrameBox クラス:
public class JInternalFrameBox extends JInternalFrame {
(...)
public JInternalFrameBox(Integer id) {
this.id = id;
setUpFrame();
}
public void setUpFrame() {
JLabel lbl = new JLabel("test");
lbl.setVisible(true);
this.add(lbl);
this.setPreferredSize(INTERNAL_FRAME_SIZE);
this.setLocation(100, 100);
this.setIconifiable(true);
this.setClosable(true);
this.pack();
this.setVisible(true);
}
}
jButtonBox JInternalFrameBox を開くボタン:
public class jButtonBox extends JButton implements MouseListener {
public void mouseReleased(MouseEvent e) {
JInternalFrameBox jifb = new JInternalFrameBox(id);
jifb.setVisible(true);
Desktop df = Desktop.getInstance();
df.addJInternalFrameBox(jifb);
}
(...)
}