JScrollPane dans une JInternalFrame contenant un graphic
Bonjour a tous,
Voila mon probleme, j'essaye simplement d'ajouter un JScrollPane dans une JInternalFrame ne contenant qu'un simple graphic (JComponent) .
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
Container content = this.getContentPane();
JPanel panelGene = new JPanel(new BorderLayout());
getContentPane().setBackground(new Color(0, 0, 0));
this.setTitle("Generation screen");
this.setVisible(true);
princ = new Papier();
js = new JScrollPane(princ);
js.setViewportView(princ);
js.setVisible(true);// Indispensable ?
js.setEnabled(true);// Idem ?
//js.add(princ); AFFICHE un écran blanc
//js.createVerticalScrollBar();
//js.createHorizontalScrollBar();
//js.setPreferredSize(new Dimension(600, 150));
//js.setMinimumSize(js.getPreferredSize);
//js.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
panelGene.add(js, BorderLayout.CENTER);
content.add(panelGene);
//content.add(princ);
Graphics g = js.getGraphics();
js.paint(g);
//js.validate();
//princ.getGraphics();
//princ.paint(g);
princ.start(); |
J'ai essayé toutes les solutions que j'ai trouvé sur le forum... en vain :aie:
J'ai laissé en commentaire une partie des solutions que j'ai essayé.
princ => class Papier extends JComponent qui dessine et contient la methode paint.
[EDIT]
J'ai chercher une nouvelle methode qui consiste a afficher en permanence les JscrolleBar. Les ScrollBar apparaisse donc mais impossible de defiler car pour elle il n'y a rien a defiler !!!
Code:
1 2 3
|
js.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
js.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); |
Voila sinon rien de neuf
[/EDIT]