📄 lleuro.java
字号:
//Michel Tawil LLEURO.java
import java.awt.*;
import java.awt.event.*;
public class LLEURO extends Frame implements ActionListener
{
private Button convertir,convertir1;
private TextField LL,EURO;
private Label lLL,lEURO,lfenetre;
public LLEURO(String title)
{
super(title);
convertir=new Button("convertir en EURO");
convertir1 = new Button("convertir en LL");
LL=new TextField("",25);
EURO=new TextField("",25);
lLL=new Label("Livre Libanaise");
lEURO=new Label("EURO");
lfenetre=new Label("LLEURO");
Panel pLL=new Panel();
pLL.setLayout(new FlowLayout());
pLL.add(lLL);
pLL.add(LL);
Panel pEURO=new Panel();
pEURO.setLayout(new FlowLayout());
pEURO.add(lEURO);
pEURO.add(EURO);
Panel p0 =new Panel();
p0.add(lfenetre,BorderLayout.CENTER);
Panel p1=new Panel();
p1.add(pLL);
p1.add(pEURO);
Panel p3 = new Panel();
p3.setLayout(new FlowLayout());
p3.add(convertir);
p3.add(convertir1);
this.add(p0, BorderLayout.NORTH);
this.add(p1, BorderLayout.CENTER);
this.add(p3,BorderLayout.SOUTH);
this.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
);
convertir.addActionListener(this);
convertir1.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == convertir)
{
String getval = LL.getText();
try
{
Float val = Float.parseFloat(getval);
double coef = 0.0005231; //1507,5LL=1,268EURO
double res = val * coef;
EURO.setText(String.valueOf(res));
}
catch (NumberFormatException excep)
{
System.err.println("Entrer un nombre");
}
}
if (e.getSource() == convertir1)
{
String getval = EURO.getText();
try
{
Float val = Float.parseFloat(getval);
double coef = 0.0005231; //1507,5LL=0.7886435EURO
double res = val / coef;
LL.setText(String.valueOf(res));
}
catch (NumberFormatException excep)
{
System.err.println("Entrer un nombre");
}
}
else return;
}
public static void main(String argv[])
{
LLEURO a=new LLEURO("LLEURO");
a.pack();
a.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -