Question

J'ai eu un dialogue assez simple avec une paire de JPanels de taille à peu près égale, contenus dans un JSplitPane. Maintenant, je cherche à ajouter un 3ème JPanel et je ne suis pas sûr qu'il existe une solution évidente. Existe-t-il un bon cadre de fenêtre amarrée? ou est-ce une chose terriblement complexe dans laquelle entrer? Si je ne fais que rester avec la division à 3 panneaux, dois-je utiliser une paire de JSplitPanes imbriqués ou existe-t-il une alternative permettant une division à 3 voies?

Était-ce utile?

La solution

La

bibliothèque SwingX contient JXMultiSplitPane , qui vous permet de créer des mises en page de panneaux redimensionnables.

Un très bon article à ce sujet se trouve sur http://today.java.net/pub/a/today/2006/03/23/multi-split-pane.html

Autres conseils

Disons que vous avez trois panneaux:

JPanel panel1;
JPanel panel2;
JPanel panel3;

// set up panels
...

// put three panels into a horizontal split pane,
// with 2 resizeable dividers
JSplitPane splitPaneLeft = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
JSplitPane splitPaneRight = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitPaneLeft.setLeftComponent( panel1 );
splitPaneLeft.setRightComponent( panel2 );
splitPaneRight.setLeftComponent( splitPaneLeft );
splitPaneRight.setRightComponent( panel3 );

// put splitPaneRight onto a single panel
JPanel panelSplit = new JPanel();
panelSplit.add( splitPaneRight );
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top