Java - How to make a set of JInternalFrame independant of each other?
Posted
by Amokrane
on Stack Overflow
See other posts from Stack Overflow
or by Amokrane
Published on 2010-03-20T01:22:21Z
Indexed on
2010/03/20
1:31 UTC
Read the original article
Hit count: 418
Hello,
I'm programming a short Paint program like and I'm trying to make an MDI architecture for it. To make that happen, I used JInternalFrame inside a JDesktopPane. Although I kind of obtain multiple frames, there are not really working properly. Basically, if I have 2 JInternalFrame I can draw only on the last one. The other one seems to be disabled.
Here is a short video illustrating the problem. http://bit.ly/9ydiwM
Here are some part of the code.
Panneau.java
public class Panneau extends JDesktopPane
{
/** La liste de fenêtres ouvertes */
private static ArrayList<Cadre> cadres;
/** Le pannel comportant la liste des formes à dessiner*/
private Pannel pannel;
/** La barre d'outils */
private ToolBox toolBox;
public Panneau()
{
this.setLayout(new BorderLayout());
// Initialisations des listes de cadres
cadres = new ArrayList<Cadre>();
// En haut ToolBox
toolBox = new ToolBox();
this.add(toolBox, BorderLayout.NORTH);
**// Intialisation de la première internal frame
Cadre cadre = new Cadre();
this.add(cadre, BorderLayout.CENTER);**
cadres.add(cadre);
// Ajout du pannel à gauche
pannel = new Pannel();
this.add(pannel, BorderLayout.WEST);
}
/**
* Crée une nouvelle fenêtre de dessin
*
*/
**public void createNewInternalFrame()
{
Cadre cadre = new Cadre();
this.add(cadre, BorderLayout.CENTER);
cadres.add(cadre);
}**
}
public class Cadre extends JInternalFrame
{
/** Largeur par d'une fenêtre interne */
private int width;
/** Hauteur d'une fenêtre interne */
private int height;
/** Titre d'une fenêtre interne */
private String title;
/** Toile associée à la fenêtre interne */
private Toile toile;
public Cadre()
{
width = 400;
height = 400;
title = "Form";
toile = new Toile();
this.setTitle(title);
this.setSize(width, height);
this.setEnabled(true);
this.setResizable(true);
this.setAutoscrolls(true);
this.setClosable(true);
this.setIconifiable(true);
this.setDoubleBuffered(true);
this.setContentPane(toile);
this.setVisible(true);
this.pack();
}
}
Basically, Panneau is the main Window that contains all the differents parts of the GUI. I can create as much JInternalFrame that I want, using : Panneau.createNewInternalFrame(). Toile is basically where I draw my shapes.
Any idea ?
Thanks
© Stack Overflow or respective owner