欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

退出的java代碼,java中退出程序的代碼

實現(xiàn)界面登陸,退出功能的java代碼怎么寫?

CS結(jié)構(gòu)系統(tǒng)的退出如下:public void init() {

成都創(chuàng)新互聯(lián)長期為上1000家客戶提供的網(wǎng)站建設(shè)服務(wù),團隊從業(yè)經(jīng)驗10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為牡丹江企業(yè)提供專業(yè)的成都做網(wǎng)站、成都網(wǎng)站設(shè)計,牡丹江網(wǎng)站改版等技術(shù)服務(wù)。擁有十余年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。

this.setTitle("用戶登錄界面");

this.add(createCenterPane());

this.setDefaultCloseOperation(this.DO_NOTHING_ON_CLOSE);

this.setSize(new Dimension(450, 335));

this.setLocationRelativeTo(null);

// this.setVisible(true);

this.addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent e) {

int choose = JOptionPane.showConfirmDialog(null, "是否要退出登錄界面?",

"系統(tǒng)提示:", JOptionPane.YES_NO_OPTION);

if (choose == JOptionPane.YES_OPTION) {

System.exit(1);

}

}

});

}其中this為JFrame對象。BS結(jié)構(gòu)的退出直接用windows.close()方法就行了!

java關(guān)閉當前窗口代碼

方法一:

類 JFrame

javax.swing.JFrame

JFrame中的方法void setDefaultCloseOperation(int)可以設(shè)置

以下為改方法的用法:

setDefaultCloseOperation

public void setDefaultCloseOperation(int operation)設(shè)置用戶在此窗體上發(fā)起

"close" 時默認執(zhí)行的操作。必須指定以下選項之一:

DO_NOTHING_ON_CLOSE(在 WindowConstants 中定義):不執(zhí)行任何操作;要求程序在已注冊的

WindowListener 對象的 windowClosing 方法中處理該操作。

HIDE_ON_CLOSE(在 WindowConstants 中定義):調(diào)用任意已注冊的 WindowListener

對象后自動隱藏該窗體。

DISPOSE_ON_CLOSE(在 WindowConstants 中定義):調(diào)用任意已注冊 WindowListener

的對象后自動隱藏并釋放該窗體。

EXIT_ON_CLOSE(在 JFrame 中定義):使用 System exit

方法退出應用程序。僅在應用程序中使用。

默認情況下,該值被設(shè)置為 HIDE_ON_CLOSE。更改此屬性的值將導致激發(fā)屬性更改事件,其屬性名稱為

"defaultCloseOperation"。

注:當 Java 虛擬機 (VM) 中最后一個可顯示窗口被釋放后,虛擬機可能會終止

要實現(xiàn)你說的,應該采用

setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

方法二:

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import javax.swing.JFrame;

import javax.swing.JOptionPane;

public class Test extends JFrame {

public Test(){

this.setTitle("title");

this.setSize(300,200);

this.setLocation(100,100);

//設(shè)置關(guān)閉時什么也不做

this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

//監(jiān)聽關(guān)閉按鈕的點擊操作

this.addWindowListener(new WindowAdapter(){

//new 一個WindowAdapter 類 重寫windowClosing方法

//WindowAdapter是個適配器類 具體看jdk的幫助文檔

public void windowClosing(WindowEvent e) {

//這里寫對話框

if(JOptionPane.showConfirmDialog(null,

"退出","提

示",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE)==JOptionPane.YES_OPTION){

System.exit(0);

}

}

});

this.setVisible(true);

}

public static void main(String[] args) {

new Test();

}

}

Java中執(zhí)行退出(結(jié)束)程序的語句是什么?

System.exit(-1)終止當前正在運行的 Java 虛擬機,退出程序。其中參數(shù)按照慣例,是用非零的參數(shù)碼表示異常終止。

JAVA 中 按回車鍵退出的 程序代碼怎么寫?

import java.io.IOException;

public class TestEnter {

public static void main(String[] args) throws IOException{

while(true){

if(System.in.read() == '\n')

System.exit(0);

}

}

}

實現(xiàn) 界面登陸 退出 功能的java代碼雜寫

CS結(jié)構(gòu)系統(tǒng)的退出如下:public void init() {

this.setTitle("用戶登錄界面");

this.add(createCenterPane());

this.setDefaultCloseOperation(this.DO_NOTHING_ON_CLOSE);

this.setSize(new Dimension(450, 335));

this.setLocationRelativeTo(null);

// this.setVisible(true);

this.addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent e) {

int choose = JOptionPane.showConfirmDialog(null, "是否要退出登錄界面?",

"系統(tǒng)提示:", JOptionPane.YES_NO_OPTION);

if (choose == JOptionPane.YES_OPTION) {

System.exit(1);

}

}

});

}其中this為JFrame對象。BS結(jié)構(gòu)的退出直接用windows.close()方法就行了!

本文題目:退出的java代碼,java中退出程序的代碼
本文鏈接:http://chinadenli.net/article14/hecege.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護網(wǎng)頁設(shè)計公司企業(yè)網(wǎng)站制作電子商務(wù)品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

小程序開發(fā)