View Single Post
Old 25-02-2004, 15:01   #3
anx721
Senior Member
 
L'Avatar di anx721
 
Iscritto dal: Oct 2002
Cittā: Roma
Messaggi: 1502
Sicuramente sbagli qlcosa da qlche altra parte, quel codice funziona benissimo:

Codice PHP:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import java.util.*;
import javax.swing.border.*;


class 
RicercaBloccatiAction extends AbstractAction
  
{
      
      
JDesktopPane desktop;
      
JMenuItem tempItem ;
      
      
RicercaBloccatiAction(JDesktopPane desktop)
      {
          
super("Allegati bloccati");
          
this.desktop = desktop;
          
      }
      
      public 
void actionPerformed(ActionEvent e)
      {
          
tempItem = (JMenuItem)e.getSource();
    
          
TrovaAllegatiBloccatiFrame trovaAllegatiBloccatiFrame = new TrovaAllegatiBloccatiFrame(tempItem.getText());
          
trovaAllegatiBloccatiFrame.setSize(150, 150);
          
trovaAllegatiBloccatiFrame.setVisible(true);
          
          
          
tempItem.setEnabled(false);
         
         
System.out.println("appena disabilitato" + tempItem.getText());
                     
          
desktop.add(trovaAllegatiBloccatiFrame);
            
trovaAllegatiBloccatiFrame.moveToFront();
  
      
trovaAllegatiBloccatiFrame.addInternalFrameListener(new InternalFrameAdapter()
      {
        public 
void internalFrameClosing(InternalFrameEvent ife)  {
         
            
tempItem.setEnabled(true);
            
System.out.println("appena abilitato" + tempItem.getText());
         
           }
      });
      }
  }


class 
TrovaAllegatiBloccatiFrame extends JInternalFrame{

public 
TrovaAllegatiBloccatiFrame(String title){
        
super(title,
           
true, //resizable
           
true, //closable
           
true, //maximizable
          
true);//iconifiable
          
}
}


public class 
Ciao extends JFrame{

    
JDesktopPane desktop;

    public 
Ciao(){
        
addWindowListener(new WindowAdapter(){
            public 
void windowClosing(WindowEvent e){
                
System.exit(0);
            }
        });

        
desktop = new JDesktopPane();
        
getContentPane().add(desktop);
        
setTitle("Ciao");
        
setSize(340, 340);
        
        
JMenuBar bar = new JMenuBar();
        
JMenu menu = new JMenu("uffa");
        
JMenuItem item = new JMenuItem("ciao 1");
        
item.addActionListener(new RicercaBloccatiAction(desktop));
        
menu.add(item);
        
bar.add(menu);
        
        
item = new JMenuItem("ciao 2");
        
item.addActionListener(new RicercaBloccatiAction(desktop));
        
menu.add(item);
        
        
item = new JMenuItem("ciao 3");
        
item.addActionListener(new RicercaBloccatiAction(desktop));
        
menu.add(item);
        
        
getContentPane().add(bar, "North");

        
setLocation(0, 0);
        
validate();
        
show();
        
    }
    
    public static 
void main(String[] args){
        new 
Ciao();
        
    }
} 
ciao.
__________________
Sun Certified Java Programmer
EUCIP Core Level Certified

European Certification of Informatics Professionals

Ultima modifica di anx721 : 25-02-2004 alle 15:14.
anx721 č offline   Rispondi citando il messaggio o parte di esso