📄 frame_interpolator.java
字号:
package interpolator;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import com.borland.jbcl.layout.*;
public class Frame_Interpolator extends JFrame {
JPanel contentPane;
Border border1;
XYLayout xYLayout1 = new XYLayout();
JButton jButton1 = new JButton();
JTextArea show_result = new JTextArea();
Border border2;
Border border3;
JLabel jLabel2 = new JLabel();
JTextField strXinput = new JTextField();
JLabel jLabel1 = new JLabel();
JLabel jLabel3 = new JLabel();
JTextField strYinput = new JTextField();
JTextField strTinput = new JTextField();
//Construct the frame
public Frame_Interpolator() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
border1 = BorderFactory.createLineBorder(Color.white,1);
border2 = new EtchedBorder(EtchedBorder.RAISED,new Color(255, 255, 244),new Color(142, 161, 119));
border3 = BorderFactory.createBevelBorder(BevelBorder.RAISED,Color.white,Color.white,new Color(102, 109, 105),new Color(147, 156, 151));
contentPane.setLayout(xYLayout1);
this.setSize(new Dimension(446, 292));
this.setTitle("Java插值器");
contentPane.setBackground(new Color(212, 208, 255));
contentPane.setEnabled(false);
contentPane.setMinimumSize(new Dimension(438, 261));
contentPane.setPreferredSize(new Dimension(500, 300));
jButton1.setBackground(new Color(210, 249, 184));
jButton1.setAlignmentY((float) 0.5);
jButton1.setBorder(border3);
jButton1.setText("插 值 计 算");
jButton1.addActionListener(new Frame_Interpolator_jButton1_actionAdapter(this));
show_result.setBackground(new Color(203, 230, 255));
show_result.setBorder(border2);
show_result.setCaretPosition(0);
show_result.setText("show_result");
jLabel2.setAlignmentX((float) 0.3);
jLabel2.setAlignmentY((float) 0.3);
jLabel2.setMaximumSize(new Dimension(50, 16));
jLabel2.setMinimumSize(new Dimension(50, 16));
jLabel2.setPreferredSize(new Dimension(50, 16));
jLabel2.setHorizontalAlignment(SwingConstants.TRAILING);
jLabel2.setText("给定节点的X值:");
jLabel2.setVerticalAlignment(SwingConstants.CENTER);
strXinput.setBorder(BorderFactory.createLineBorder(Color.black));
strXinput.setPreferredSize(new Dimension(200, 25));
strXinput.setCaretPosition(0);
strXinput.setText("0.10,0.15,0.25,0.40,0.50,0.57,0.70,0.85,0.93,1.00");
strXinput.setHorizontalAlignment(SwingConstants.LEADING);
jLabel1.setAlignmentX((float) 0.3);
jLabel1.setAlignmentY((float) 0.3);
jLabel1.setMaximumSize(new Dimension(50, 16));
jLabel1.setMinimumSize(new Dimension(50, 16));
jLabel1.setOpaque(false);
jLabel1.setPreferredSize(new Dimension(50, 16));
jLabel1.setHorizontalAlignment(SwingConstants.TRAILING);
jLabel1.setText("给定节点的Y值:");
jLabel3.setText("插值点的X值:");
jLabel3.setHorizontalAlignment(SwingConstants.TRAILING);
jLabel3.setPreferredSize(new Dimension(50, 16));
jLabel3.setOpaque(false);
jLabel3.setMinimumSize(new Dimension(50, 16));
jLabel3.setMaximumSize(new Dimension(50, 16));
jLabel3.setAlignmentY((float) 0.3);
jLabel3.setAlignmentX((float) 0.3);
strYinput.setBorder(BorderFactory.createLineBorder(Color.black));
strYinput.setPreferredSize(new Dimension(200, 25));
strYinput.setCaretPosition(0);
strYinput.setText("0.904837,0.860708,0.778801,0.670320,0.606531,0.565525,0.496585,0.427415,0.394554,0.367879");
strTinput.setText("0.63");
strTinput.setPreferredSize(new Dimension(200, 25));
strTinput.setCaretPosition(0);
strTinput.setBorder(BorderFactory.createLineBorder(Color.black));
contentPane.add(jButton1, new XYConstraints(66, 103, 213, 23));
contentPane.add(show_result, new XYConstraints(25, 142, 388, 132));
contentPane.add(jLabel2, new XYConstraints(1, 3, 92, 24));
contentPane.add(strXinput, new XYConstraints(99, 0, 318, 24));
contentPane.add(jLabel1, new XYConstraints(1, 27, 95, 24));
contentPane.add(jLabel3, new XYConstraints(0, 51, 95, 24));
contentPane.add(strYinput, new XYConstraints(96, 25, 319, 24));
contentPane.add(strTinput, new XYConstraints(98, 52, 319, 24));
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
void jButton1_actionPerformed(ActionEvent e) {
CInterpolator cinter =new CInterpolator();
String result="";
if(cinter.GetNodesFromString(strXinput.getText(),strYinput.getText(),strTinput.getText(),","))
{
result= cinter.res2str();
}else{
result = "在获得节点时存在错误";
}
show_result.setText(result);
}
}
class Frame_Interpolator_jButton1_actionAdapter implements java.awt.event.ActionListener {
Frame_Interpolator adaptee;
Frame_Interpolator_jButton1_actionAdapter(Frame_Interpolator adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -