📄 loaneditor.java
字号:
import java.beans.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class LoanEditor extends JPanel implements ActionListener,PropertyEditor
{
JLabel labelCarLoan;
JLabel labelPersonalLoan;
JLabel labelHouseLoan;
JTextField textCarLoan;
JTextField textPersonalLoan;
JTextField textHouseLoan;
JPanel panel;
String[] interestRates = {"","",""};
public void setValue(Object temp)
{
interestRates = (String[]) temp ;
textCarLoan.setText(interestRates[0]);
textPersonalLoan.setText(interestRates[1]);
textHouseLoan.setText(interestRates[2]);
}
public Object getValue()
{
interestRates[0]=textCarLoan.getText();
interestRates[1]=textPersonalLoan.getText();
interestRates[2]=textHouseLoan.getText();
return interestRates ;
}
public Component getCustomEditor(){return this;}
public LoanEditor()
{
labelCarLoan = new JLabel("Car Loan");
labelPersonalLoan = new JLabel("Personal Loan");
labelHouseLoan = new JLabel("House Loan");
panel = new JPanel();
setLayout(new BorderLayout());
panel.setLayout(new GridLayout(3,2));
//Initializing text boxes
textCarLoan = new JTextField(10);
textPersonalLoan = new JTextField(10);
textHouseLoan = new JTextField(10);
//submit = new JButton("Submit");
//Adding controls for Applicant AccountId
panel.add(labelCarLoan);
panel.add(textCarLoan);
//Adding controls for Applicant Address
panel.add(labelPersonalLoan);
panel.add(textPersonalLoan);
//Adding controls for Applicant Phone
panel.add(labelHouseLoan);
panel.add(textHouseLoan);
add(new JPanel(),BorderLayout.WEST);
add(new JPanel(),BorderLayout.EAST);
add(panel,BorderLayout.CENTER);
//add(submit,BorderLayout.SOUTH);
textCarLoan.addActionListener(this) ;
textPersonalLoan.addActionListener(this) ;
textHouseLoan.addActionListener(this);
//submit.addActionListener(this);
}
public void actionPerformed(ActionEvent te)
{
interestRates[0]=textCarLoan.getText();
interestRates[1]=textPersonalLoan.getText();
interestRates[2]=textHouseLoan.getText();
}
/* You need not explore on the following methods. These are abstract methods of the PropertyEditor class. */
public boolean isPaintable(){ return true;}
public void paintValue(Graphics g,Rectangle r){}
public String getJavaInitializationString(){ return null;}
public String getAsText(){return null;}
public void setAsText(String s) throws
IllegalArgumentException{}
public String[] getTags(){ return null;}
public boolean supportsCustomEditor(){ return true;}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -