當前位置: 首頁>>代碼示例>>Java>>正文


Java WindowAdapter類代碼示例

本文整理匯總了Java中java.awt.event.WindowAdapter的典型用法代碼示例。如果您正苦於以下問題:Java WindowAdapter類的具體用法?Java WindowAdapter怎麽用?Java WindowAdapter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


WindowAdapter類屬於java.awt.event包,在下文中一共展示了WindowAdapter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: GWMCratesGUI

import java.awt.event.WindowAdapter; //導入依賴的package包/類
public GWMCratesGUI() {
    super("GWMCrates v" + GWMCrates.VERSION + " GUI");
    setSize(800, 600);
    setResizable(false);
    setLocationRelativeTo(null);
    setLayout(null);
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    createObjects();
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent windowEvent) {
            int result = JOptionPane.showConfirmDialog(instance, "Do you want to close " + getTitle() + "? If you have unsaved data, it will be lost permanently!", "Close?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (result == JOptionPane.YES_OPTION) {
                instance.setVisible(false);
                instance = null;
            }
        }
    });
    setVisible(true);
}
 
開發者ID:GreWeMa,項目名稱:gwm_Crates,代碼行數:21,代碼來源:GWMCratesGUI.java

示例2: showDialog

import java.awt.event.WindowAdapter; //導入依賴的package包/類
/**
 *  Show font selection dialog.
 *  @param parent Dialog's Parent component.
 *  @return OK_OPTION, CANCEL_OPTION or ERROR_OPTION
 *
 *  @see #OK_OPTION 
 *  @see #CANCEL_OPTION
 *  @see #ERROR_OPTION
 **/
public int showDialog(Component parent) {
    dialogResultValue = ERROR_OPTION;
    JDialog dialog = createDialog(parent);
    dialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            dialogResultValue = CANCEL_OPTION;
        }
    });

    dialog.setVisible(true);
    dialog.dispose();
    dialog = null;

    return dialogResultValue;
}
 
開發者ID:takun2s,項目名稱:smile_1.5.0_java7,代碼行數:27,代碼來源:FontChooser.java

示例3: initComponents

import java.awt.event.WindowAdapter; //導入依賴的package包/類
protected void initComponents() {
  setTitle("Translate " + VASSAL.configure.ConfigureTree.getConfigureName((Configurable) target));
  JPanel mainPanel = new JPanel(new BorderLayout());
  /*
   * Place Language selector above Tree and Keys
   */
  mainPanel.add(getHeaderPanel(), BorderLayout.PAGE_START);
  mainPanel.add(buildMainPanel(), BorderLayout.CENTER);
  mainPanel.add(getButtonPanel(), BorderLayout.PAGE_END);
  add(mainPanel);
  pack();
  setLocationRelativeTo(getParent());
  setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
  addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent we) {
      cancel();
    }
  });
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:20,代碼來源:TranslateWindow.java

示例4: main

import java.awt.event.WindowAdapter; //導入依賴的package包/類
/**
 * Simple test case for the gradient painter
 * 
 * @param argv The arguments supplied at the command line
 */
public static void main(String[] argv) {
	JFrame frame = new JFrame();
	JPanel panel = new JPanel();
	panel.setBorder(BorderFactory.createTitledBorder("Gradient"));
	panel.setLayout(null);
	frame.setContentPane(panel);
		
	GradientEditor editor = new GradientEditor();
	editor.setBounds(10,15,270,100);
	panel.add(editor);
	frame.setSize(300,200);
	
	frame.addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent e) {
			System.exit(0);
		}
	});
	
	frame.setVisible(true);
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:26,代碼來源:GradientEditor.java

示例5: setupUI

import java.awt.event.WindowAdapter; //導入依賴的package包/類
private void setupUI() {
    frame = new JFrame("Gradle");

    JPanel mainPanel = new JPanel(new BorderLayout());
    frame.getContentPane().add(mainPanel);

    mainPanel.add(singlePaneUIInstance.getComponent());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    singlePaneUIInstance.aboutToShow();

    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            close();
        }
    });

    frame.setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
    frame.setLocationByPlatform(true);
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:22,代碼來源:Application.java

示例6: initLayerManager

import java.awt.event.WindowAdapter; //導入依賴的package包/類
protected void initLayerManager() {

		JFrame d = new JFrame();
		d.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				((JCheckBoxMenuItem)(XML_Menu.commandToMenuItemHash.get("layer_manager_cmd"))).setSelected(false);
			}
		});
		LayerManager lm;
		
		//use existing layer manager if it already exists
		if (layerManager != null) {
			lm = layerManager;
		} else {
			lm = new LayerManager();
		}
		
		lm.setLayerList( toLayerList(map.overlays) );
		lm.setMap(map);

		lm.setDialog(d);
		JScrollPane sp = new JScrollPane(lm);
		sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		d.setTitle("Layer Manager");
		d.setContentPane(sp);
//		d.getContentPane().add(sp);
		d.pack();
		d.setSize(new Dimension(lm.getPreferredSize().width+20,lm.getPreferredSize().height+55));
		d.setMaximumSize(new Dimension(400,300));

		d.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
		d.setLocationRelativeTo(frame);
		d.setState(Frame.NORMAL);
		d.setAlwaysOnTop(true);
		this.layerManager = lm;
		this.layerManagerDialog = d;	
	}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:38,代碼來源:MapApp.java

示例7: ScreenManager

import java.awt.event.WindowAdapter; //導入依賴的package包/類
public ScreenManager(final String gameTitle) {
  super(gameTitle);
  this.resolutionChangedConsumer = new CopyOnWriteArrayList<>();
  this.screenChangedConsumer = new CopyOnWriteArrayList<>();
  this.screens = new CopyOnWriteArrayList<>();

  // set default jframe stuff
  this.setResizable(false);
  this.setBackground(Color.BLACK);
  this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
  final RenderComponent comp = new RenderComponent(Game.getConfiguration().graphics().getResolution());
  this.add(comp);
  this.renderCanvas = comp;
  this.getRenderComponent().addComponentListener(new ResizedEventListener());

  this.addWindowStateListener(this);
  this.addWindowFocusListener(this);
  this.addWindowListener(new WindowAdapter() {
    @Override
    public void windowClosing(final WindowEvent event) {
      // ensures that we terminate the game, when the window is being closed
      Game.terminate();
    }
  });
}
 
開發者ID:gurkenlabs,項目名稱:litiengine,代碼行數:27,代碼來源:ScreenManager.java

示例8: main

import java.awt.event.WindowAdapter; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    PandomiumSettings settings = PandomiumSettings.getDefaultSettings();

    Pandomium pandomium = new Pandomium(settings);
    pandomium.initialize();

    PandomiumClient client = pandomium.createClient();
    PandomiumBrowser browser = client.loadURL("https://google.pl/");

    JFrame frame = new JFrame();
    frame.getContentPane().add(browser.toAWTComponent(), BorderLayout.CENTER);

    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            pandomium.dispose();
            frame.dispose();
        }
    });

    frame.setTitle("Pandomium");
    frame.setSize(1720, 840);
    frame.setVisible(true);
}
 
開發者ID:Panda-Programming-Language,項目名稱:Pandomium,代碼行數:26,代碼來源:PandomiumTest.java

示例9: openBrandingEditor

import java.awt.event.WindowAdapter; //導入依賴的package包/類
/**
 * Opens branding editor for given project. Must be invoked from EDT.
 * @param displayName Editor's display name.
 * @param p Project to be branded.
 * @param model a branding model to use
 */
public static void openBrandingEditor(String displayName, final Project p, BrandingModel model) {
    if( !SwingUtilities.isEventDispatchThread() ) {
        throw new IllegalStateException("This method must be invoked from EDT."); //NOI18N
    }
    synchronized( project2dialog ) {
        Dialog dlg = project2dialog.get(p);
        if( null == dlg ) {
            BrandingEditorPanel editor = new BrandingEditorPanel(displayName, model);
            dlg = editor.open();
            project2dialog.put(p, dlg);
            dlg.addWindowListener( new WindowAdapter() {
                @Override public void windowClosed(WindowEvent e) {
                    synchronized( project2dialog ) {
                        project2dialog.remove(p);
                    }
                }
            });
        } else {
            dlg.setVisible(true);
            dlg.requestFocusInWindow();
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:30,代碼來源:BrandingUtils.java

示例10: init

import java.awt.event.WindowAdapter; //導入依賴的package包/類
private void init(GUIFramework framework) {
    this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    this.setTitle(GlobalResourcesManager
            .getString("CreateAttributeDialog.Title"));
    this.engine = framework.getEngine();
    this.framework = framework;
    this.accessRules = framework.getAccessRules();
    Options.loadOptions(this);
    init();
    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            Options.saveOptions(AttributePreferenciesDialog.this);
        }
    });
    setMinimumSize(getSize());
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:18,代碼來源:AttributePreferenciesDialog.java

示例11: run2

import java.awt.event.WindowAdapter; //導入依賴的package包/類
private void run2() {
    //
    // Start process
    //
    ptyProcess = executor.start(program, term);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            try {
                ptyProcess.hangup();
            } catch (IllegalStateException x) {
            }
        }
    });

    // Make main window visible
    setVisible(true);

    //
    // Wait for process to exit
    //
    ptyProcess.waitFor();

    dispose();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:Terminal.java

示例12: addNotify

import java.awt.event.WindowAdapter; //導入依賴的package包/類
@Override
public void addNotify () {
    super.addNotify ();
    //show progress for initialize method
    final Window w = findWindowParent ();
    if (w != null) {
        w.addWindowListener (new WindowAdapter (){
            @Override
            public void windowOpened (WindowEvent e) {
                final WindowAdapter waa = this;
                setWaitingState (true);
                Utilities.startAsWorkerThread (PluginManagerUI.this,
                        new Runnable () {
                            @Override
                            public void run () {
                                try {
                                    initTask.waitFinished ();
                                    w.removeWindowListener (waa);
                                } finally {
                                    setWaitingState (false);
                                }
                            }
                        },
                        NbBundle.getMessage (PluginManagerUI.class, "UnitTab_InitAndCheckingForUpdates"),
                        Utilities.getTimeOfInitialization ());
            }
        });
    }
    HelpCtx.setHelpIDString (this, PluginManagerUI.class.getName ());
    tpTabs.addChangeListener (new ChangeListener () {
        @Override
        public void stateChanged (ChangeEvent evt) {
            HelpCtx.setHelpIDString (PluginManagerUI.this, getHelpCtx ().getHelpID ());
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:37,代碼來源:PluginManagerUI.java

示例13: TableExample2

import java.awt.event.WindowAdapter; //導入依賴的package包/類
public TableExample2(String URL, String driver, String user,
        String passwd, String query) {
    JFrame frame = new JFrame("Table");
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    JDBCAdapter dt = new JDBCAdapter(URL, driver, user, passwd);
    dt.executeQuery(query);

    // Create the table
    JTable tableView = new JTable(dt);

    JScrollPane scrollpane = new JScrollPane(tableView);
    scrollpane.setPreferredSize(new Dimension(700, 300));

    frame.getContentPane().add(scrollpane);
    frame.pack();
    frame.setVisible(true);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:24,代碼來源:TableExample2.java

示例14: showJFreeChart

import java.awt.event.WindowAdapter; //導入依賴的package包/類
public void showJFreeChart(int coordX, int coordY){
        //Mostrar el chart
        ChartPanel chartPanel = new ChartPanel(chart1);
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
        setContentPane(chartPanel);           
                
        this.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);               
        
        addWindowListener(
        		new WindowAdapter(){
        		        public void WindowClosing (WindowEvent e){
                           System.out.println("No quiero cerrar la ventana !!!\n");
        		        }	
        		}
        );

        
        this.pack();
//        RefineryUtilities.centerFrameOnScreen(this);
        
        this.setLocation(coordX, coordY);
        
        this.setVisible(true);    	    	
    }
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:25,代碼來源:VisualizacionJfreechart.java

示例15: imprevisto

import java.awt.event.WindowAdapter; //導入依賴的package包/類
/**
 * Nel momento in cui viene chiuso il programma prima della fine del processo di inizializzazione
 */
public void imprevisto(){
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent we) {
            int i = JOptionPane.showConfirmDialog(rootPane, "Sei sicuro di voler uscire?");
            if(i==JOptionPane.YES_OPTION){
                try {
                    createDb.DropSchema();
                    dispose();
                } catch (SQLException ex) {
                    JOptionPane.showMessageDialog(rootPane, "Impossibile raggiungere il Database!");
                }  
            }else
                setDefaultCloseOperation(GuiNome.DO_NOTHING_ON_CLOSE);
        }
    });
}
 
開發者ID:IngSW-unipv,項目名稱:Progetto-N,代碼行數:21,代碼來源:GuiInputSale.java


注:本文中的java.awt.event.WindowAdapter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。