Les menu s affiche l un sur l autre

Résolu
fatimazahrazaidi Messages postés 29 Date d'inscription samedi 12 mai 2007 Statut Membre Dernière intervention 19 décembre 2009 - 9 avril 2008 à 14:11
extraman1 Messages postés 103 Date d'inscription lundi 8 septembre 2003 Statut Membre Dernière intervention 26 décembre 2009 - 10 avril 2008 à 22:12
salut,
je veux savoir pourquoi les menu de choix s affiche l un sur l autre,
qu est ce qu il manque dans le code
merci d avance
import

java.awt.*;
import

java.awt.event.*;

import

javax.swing.*;
import

javax.swing.table.DefaultTableModel;

public

class FrmChart
extends JFrame{

private
static
final
long
serialVersionUID = 1L;DefaultTableModel

tmn =
null ;

public FrmChart(){

super();setSize( 500, 500 );

setTitle(

"Dessine un graph" );getContentPane().setLayout(

new BorderLayout() );

// la tableJScrollPane PETITsclp =

new JScrollPane();PETITsclp.setPreferredSize(

new Dimension( 100, 500 ) );Choice choix1=

new Choice();PETITsclp.getViewport().add( choix1 );

Choice choix2 =

new Choice();PETITsclp.getViewport().add( choix2 );

JPanel pnl =

new JPanel();getContentPane().add( pnl, BorderLayout.

WEST );pnl.setLayout(

new BorderLayout() );pnl.add(PETITsclp, BorderLayout.

CENTER );JButton btn =

new JButton(
"tracer" );pnl.add( btn, BorderLayout.

SOUTH );

// determine l action du bouton (ajoute une ligne)btn.addActionListener(

new ActionListener() {

public
void actionPerformed(ActionEvent e) {} } );}

public
static
void main(String[] args){

new FrmChart().setVisible(
true );}}

1 réponse

extraman1 Messages postés 103 Date d'inscription lundi 8 septembre 2003 Statut Membre Dernière intervention 26 décembre 2009 2
10 avril 2008 à 22:12
Salut,





Remplace ça :





Choice choix1=




new

Choice();PETITsclp.getViewport().add( choix1 );

Choice choix2=



new

Choice();PETITsclp.getViewport().add( choix2 );


par




        Choice choix1=new Choice();
        choix1.add("A");
        Choice choix2=new Choice();
        choix2.add("B");
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(choix1, BorderLayout.NORTH);
        panel.add(choix2, BorderLayout.CENTER);
       
        PETITsclp.getViewport().add(panel);

Voilà A++

extraman1
3
Rejoignez-nous