📄 matrixparameter.java
字号:
package webmath;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Matrixparameter extends JFrame
{
Panel1 panel1;
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
Button button1 = new Button();
Button button2 = new Button();
JFormattedTextField textField1 = new JFormattedTextField();
JFormattedTextField textField2 = new JFormattedTextField();
public Matrixparameter(Panel1 panel1)
{
try
{
jbInit();
this.panel1 = panel1;
} catch (Exception e)
{
e.printStackTrace();
}
}
private void jbInit() throws Exception
{
setBounds(200, 200, 380, 230);
setResizable(false);
this.setTitle("矩阵参数输入");
this.getContentPane().setBackground(Color.pink);
this.setForeground(Color.black);
// this.setLocale(java.util.Locale.getDefault());
this.getContentPane().setLayout(null);
jLabel1.setForeground(Color.red);
jLabel1.setText("行数:");
jLabel1.setBounds(new Rectangle(34, 80, 31, 23));
jLabel2.setBounds(new Rectangle(213, 80, 31, 23));
jLabel2.setForeground(Color.red);
jLabel2.setText("列数:");
jLabel3.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel3.setForeground(Color.red);
jLabel3.setText("请输入你所需要的矩阵的行数和列数:");
jLabel3.setBounds(new Rectangle(6, 19, 250, 38));
button1.setBackground(Color.pink);
button1.setLabel("OK");
button1.setBounds(new Rectangle(87, 137, 71, 25));
button1.addActionListener(new Matrixparameter_button1_actionAdapter(this));
button2.setBounds(new Rectangle(226, 137, 71, 25));
button2.addActionListener(new Matrixparameter_button2_actionAdapter(this));
button2.setLabel("Cancle");
button2.setBackground(Color.pink);
textField1.setText("");
textField1.setBounds(new Rectangle(64, 78, 89, 29));
textField2.setText("");
textField2.setBounds(new Rectangle(249, 79, 90, 31));
this.getContentPane().add(jLabel1, null);
this.getContentPane().add(jLabel2, null);
this.getContentPane().add(jLabel3, null);
this.getContentPane().add(button1, null);
this.getContentPane().add(button2, null);
this.getContentPane().add(textField1, null);
this.getContentPane().add(textField2, null);
}
void button1_actionPerformed(ActionEvent e)
{
String rowcount, tiercount;
rowcount = textField1.getText();
tiercount = textField2.getText();
if (rowcount != null && tiercount != null)
{
int irowcount = 0, itiercount = 0;
try
{
irowcount = Integer.parseInt(rowcount);
itiercount = Integer.parseInt(tiercount);
} catch (NumberFormatException ne)
{
this.hide();
textField1.setText("");
textField2.setText("");
return;
}
if (irowcount != 0 && itiercount != 0)
{
if (irowcount > 1 || itiercount > 1)
{
if (irowcount < 51 && itiercount < 51)
{
panel1.creatematrix(irowcount, itiercount);
}
}
}
}
this.hide();
textField1.setText("");
textField2.setText("");
}
void button2_actionPerformed(ActionEvent e)
{
this.hide();
}
}
class Matrixparameter_button1_actionAdapter implements java.awt.event.ActionListener
{
Matrixparameter adaptee;
Matrixparameter_button1_actionAdapter(Matrixparameter adaptee)
{
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e)
{
adaptee.button1_actionPerformed(e);
}
}
class Matrixparameter_button2_actionAdapter implements java.awt.event.ActionListener
{
Matrixparameter adaptee;
Matrixparameter_button2_actionAdapter(Matrixparameter adaptee)
{
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e)
{
adaptee.button2_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -