消息对话框_非模态对话框消息

2020-02-28 其他范文 下载本文

消息对话框由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“非模态对话框消息”。

import javax.swing.*;

public cla Example9_16 {

public static void main(String[] args){

WindowMe win=new WindowMe();

win.setTitle(“带消息对话框的窗口”);

win.setBounds(80,90,200,300);

}

}

import java.awt.event.*;

import java.awt.*;

import javax.swing.*;

public cla WindowMe extends JFrame implements ActionListener{ JTextField inputEnglish;

JTextArea show;

String regex=“[a-zZ-Z]+”;

WindowMe(){

inputEnglish=new JTextField(22);

inputEnglish.addActionListener(this);

show=new JTextArea();

add(inputEnglish,BorderLayout.NORTH);

add(show,BorderLayout.CENTER);

setVisible(true);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public void actionPerformed(ActionEvent e){

if(e.getSource()==inputEnglish){

String str=inputEnglish.getText();

if(str.matches(regex)){

show.append(str+“,”);

}

else

{//弹出“警告”消息对话框

JOptionPane.showMeageDialog(this,“您输入了非法字符”,“小心对话框”,JOptionPane.WARNING_MESSAGE);

inputEnglish.setText(null);

}

}

}

}

《消息对话框.docx》
将本文的Word文档下载,方便收藏和打印
推荐度:
消息对话框
点击下载文档
相关专题 非模态对话框消息 对话框 消息 非模态对话框消息 对话框 消息
[其他范文]相关推荐
    [其他范文]热门文章
      下载全文