📄 math_dialog.java
字号:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Math_Dialog extends JDialog implements ActionListener{
public JPanel p1=new JPanel();
public JPanel p2=new JPanel();
public JPanel p3=new JPanel();
public JButton b1=new JButton("确定");
public JButton b2=new JButton("取消");
public JTextField f1=new JTextField();
public JLabel l1=new JLabel("请输入阶数:");
public int exp=4;
public Math_Dialog()
{
Container c=this.getContentPane();
c.setLayout(new GridLayout(2,1));
p1.setLayout(new GridLayout(1,2));
p2.setLayout(new GridLayout(1,2));
p1.add(l1);
p1.add(f1);
p2.add(b1);
p2.add(b2);
c.add(p1);
c.add(p2);
this.setModal(true);
this.setSize(200,100);
this.setLocation(200,200);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
try{
int temp=Integer.parseInt(f1.getText());
exp=temp;
this.hide();
this.validate();
}catch(Exception ex)
{
JOptionPane.showMessageDialog(this,"输入参数不合法,请重新输入!");
}
}
else if(e.getSource()==b2)
{
this.hide();
this.validate();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -