Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Inserire un Jtree

  1. #1
    Utente di HTML.it
    Registrato dal
    Dec 2010
    Messaggi
    268

    Inserire un Jtree

    Ciao ho creato questo codice:
    codice:
    @Action
    public void showScheda_Installazione(){
            String nodeName= "root";
            String prefix;
            int startRow=0;
            prefix= "root";
           Scheda_Installazione si = new Scheda_Installazione(new Frame(), true);
           si.jLStato.setText("Nuovo");
        
           DefaultMutableTreeNode myComputer = 
    new DefaultMutableTreeNode("My Computer");
    DefaultMutableTreeNode c = 
    new DefaultMutableTreeNode("Local Disk(C:)");
    DefaultMutableTreeNode vinod = 
    new DefaultMutableTreeNode("Vinod");
    DefaultMutableTreeNode swing = 
    new DefaultMutableTreeNode("Swing");
    DefaultMutableTreeNode tr = 
    new DefaultMutableTreeNode("Tree");
    DefaultMutableTreeNode a = 
    new DefaultMutableTreeNode("3½ Floppy(A:)");
    DefaultMutableTreeNode e = 
    new DefaultMutableTreeNode("New Volume(E:)");
    c.add(vinod);
      vinod.add(swing);
      swing.add(tr);
      myComputer.add(c);
      myComputer.add(a);
      myComputer.add(e);
       JButton button = new JButton("Add Tree");
       
       tree = new JTree(myComputer);
       si.PanelTree.add(tree);
       
            si.setVisible(true);
    il problema che quando eseguo l'action mi apre la jdialog Scheda Installazione però il PanelTree è vuoto come mai?
    Grazie a tutti per l'aiuto

  2. #2
    Leggendo il tuo codice non capisco neanche cosa sia PanelTree, se è davvero un JPanel o altro...
    Comunque prova così
    codice:
       si.PanelTree.add(tree);
       si.revalidate();
       si.setVisible(true);
    lolide
    Java Programmer

    Informati

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.