JTree

demonc Messages postés 20 Date d'inscription jeudi 10 avril 2003 Statut Membre Dernière intervention 17 décembre 2005 - 12 avril 2003 à 11:17
cs_Duss Messages postés 890 Date d'inscription lundi 8 avril 2002 Statut Membre Dernière intervention 29 juillet 2004 - 12 avril 2003 à 12:45
Voila mon code . bonne chance et merci

public class JRep implements ActionListener{

private JButton b1, b2;
private JTree TreeLocal, TreeRemote;
private ImageIcon g1, d1;
private JScrollPane spL, spR;
private JPanel JRep, JLocal, JRemote, JSep;
private JComboBox CBLocal, CBRemote;
private MyJTree mjt;
private Client _client;

public JRep (Client client)
{
_client = client;

// Initialisation des JPanels principaux
JRep = new JPanel();
JRep.setLayout(new BorderLayout());

// Implémentation de la JPanel JLocal
JLocal = new JPanel();
JLocal.setBorder(new EtchedBorder());
JLocal.setLayout(new BorderLayout());

CBLocal = new JComboBox();
CBLocal.addActionListener(this);
CBLocal.setActionCommand("cblocal");

FileSystemView f = FileSystemView.getFileSystemView();
File[] f2 = f.getRoots();

for(int i=1; i<f.getRoots().length; i++)
{
CBLocal.addItem(((File)f2[i]).getAbsolutePath());
}

mjt = new MyJTree(CBLocal.getSelectedItem().toString());
TreeLocal = new JTree(mjt);
TreeLocal.resize(70, 20);

spL = new JScrollPane(TreeLocal);
spL.setPreferredSize(new Dimension(350, 200));

JLocal.add(CBLocal, BorderLayout.NORTH);
JLocal.add(spL, BorderLayout.CENTER);

// Implémentation de la JPAnel JSep
JSep = new JPanel();
JSep.setLayout(new BorderLayout());

g1 = new ImageIcon("g2.gif");
d1 = new ImageIcon("d2.gif");
b1 = new JButton(g1);
b2 = new JButton(d1);
JSep.add(b1, BorderLayout.NORTH);
JSep.add(b2, BorderLayout.SOUTH);

// Implémentation de la JPanel JRemote
JRemote = new JPanel();
JRemote.setBorder(new EtchedBorder());
JRemote.setLayout(new BorderLayout());

CBRemote = new JComboBox();
MyRemoteJTree mrjt = new MyRemoteJTree(client);
TreeRemote = new JTree();
spR = new JScrollPane(TreeRemote);
spR.setPreferredSize(new Dimension(350, 200));

JRemote.add(CBRemote, BorderLayout.NORTH);
JRemote.add(spR, BorderLayout.CENTER);

JRep.add(JLocal, BorderLayout.WEST);
JRep.add(JSep);
JRep.add(JRemote, BorderLayout.EAST);
}

public JPanel getJRep(){
return JRep;
}

public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand() == "cblocal")
{
mjt = new MyJTree(CBLocal.getSelectedItem().toString());

TreeLocal.setModel(mjt);

}
}

}

1 réponse

cs_Duss Messages postés 890 Date d'inscription lundi 8 avril 2002 Statut Membre Dernière intervention 29 juillet 2004 11
12 avril 2003 à 12:45
alors essayes
e.getActionCommand().equals("cblocal")
Duss
0
Rejoignez-nous