⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exitdialogdemo.java

📁 its a kind of tutorial.
💻 JAVA
字号:
// Filename ExitDialogDemo.java.
// Program to illustrate customisation of exit dialog.
//
// Written for JI book, Chapter 9 see text.
// Fintan Culwin, v0.2, August 1997.

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

import ExitDialog;

public class ExitDialogDemo extends    Applet
                            implements ActionListener, 
                                       WindowListener { 


Frame     itsFrame;
Label     aLabel;

MenuBar   mainMenuBar;
Menu      fileMenu;   
MenuItem  exitButton;

ExitDialog exitDialog;
   
   public void init() { 
   
      itsFrame = new Frame();
      itsFrame.addWindowListener( this);
      itsFrame.setTitle( "Exit Demo Demonstration");
      itsFrame.setBackground( Color.white);
      itsFrame.setFont( new Font( "TimesRoman", Font.PLAIN, 20));   
   
      mainMenuBar = new MenuBar();               
         fileMenu    = new Menu( "File"); 
            exitButton  = new MenuItem( "Exit ...");  
            exitButton.setActionCommand( "exit show");
            exitButton.addActionListener( this);     
         fileMenu.add( exitButton);         
      mainMenuBar.add( fileMenu);   
      itsFrame.setMenuBar( mainMenuBar);      

      exitDialog = new ExitDialog( itsFrame, this);
      
      aLabel = new Label( "hello World!");
      itsFrame.add( aLabel, "Center");
      itsFrame.setSize( itsFrame.getPreferredSize());      
      itsFrame.setVisible( true);                
   } // End init.
   

   public  void actionPerformed( ActionEvent event) {  
      if ( event.getActionCommand().equals( "exit show")) { 
         exitDialog.show();     
      } else if ( event.getActionCommand().equals( "exit please")) {  
         this.setVisible( false);
         System.exit( 0);      
      } // End if.  
   } // End actionPerformed.

   public void windowClosing( WindowEvent event) {  
      exitDialog.show();     
   } // End windowClosing .
   
   public void windowOpened( WindowEvent event)      {} // End windowOpened.    
   public void windowClosed( WindowEvent event)      {} // End windowClosed
   public void windowIconified( WindowEvent event)   {} // End windowIconified
   public void windowDeiconified(WindowEvent event)  {} // End windowDeiconified   
   public void windowActivated( WindowEvent event)   {} // End windowActivated
   public void windowDeactivated( WindowEvent event) {} // End windowDeactivated   
   

   
} // End ExitDialogDemo.       

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -