📄 dlgtext.java
字号:
package jeason;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Dlgtext extends JDialog{
private boolean check=false;
JLabel text=new JLabel( );
JButton btnOk=new JButton( );
JButton btnNo=new JButton( );
FlowLayout flowLayout1=new FlowLayout();
Dlgtext(){
this(null,"",false);
}
Dlgtext(Frame frame, String title, boolean modal){
super(frame,title,modal);
text.setText(" 你要保存吗? ");
text.setSize(200,60);
this.setSize(200,80);
this.setModal(true);
btnOk.setText("确定(Y)");
btnOk.setMnemonic('Y');
btnOk.setSize(100,20);
btnOk.addActionListener(new btnOk_actionAdapter(this));
btnNo.setText("取消(N)");
btnNo.setMnemonic('N');
btnNo.setSize(100,20);
btnNo.addActionListener(new btnNo_actionAdapter(this));
this.getContentPane().setLayout(flowLayout1);
this.getContentPane().add(text,flowLayout1);
this.getContentPane().add(btnOk,flowLayout1);
this.getContentPane().add(btnNo,flowLayout1);
}
void btnOk_actionPerformed(ActionEvent e){
this.check=true;
this.dispose();
this.hide();
}
void btnNo_actionPerformed(ActionEvent e){
this.check=false;
this.dispose();
this.hide();
}
public boolean getCheck(){
return this.check;
}
}
class btnOk_actionAdapter implements java.awt.event.ActionListener{
Dlgtext adaptee;
btnOk_actionAdapter(Dlgtext adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.btnOk_actionPerformed(e);
}
}
class btnNo_actionAdapter implements java.awt.event.ActionListener{
Dlgtext adaptee;
btnNo_actionAdapter(Dlgtext adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.btnNo_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -