package myprojects;
import java.awt.*;
import java.util.*;
import java.math.*;
public class Main extends Frame {
int beginx = 0;
int endx = 600;
double pe = 0.4;
double ph = 0.5;
double ls=2;
double ln=0.5;
double phe=ls*ph/((ls-1)*ph+1);
double phfe=ln*ph/((ln-1)*ph+1);
int pe1 =(int)( 500 * pe);
int phe1 = (int)(500 * phe);
int ph1 = (int)(500 * ph);
int phfe1 = (int)(phfe * 500);
public void paint(Graphics g) {
this.setBackground(Color.black);
g.setColor(Color.white);
g.drawLine(0, 500, 600, 500);
g.setColor(Color.white);
g.drawLine(100, 0, 100, 600);
g.setColor(Color.white);
g.drawLine(100, 500-phfe1, pe1+100 , 500-ph1);
// g.drawLine(100, phfe1, pe1+100 , ph1);
g.setColor(Color.white);
g.drawLine(pe1+100, 500-ph1, 600, 500-phe1);
// g.drawLine(pe1+100, ph1, 600, phe1);
}
public static void main(String[] args) {
Main SinFrame1 = new Main();
SinFrame1.setSize(600, 600);
SinFrame1.setLocation(0, 0);
SinFrame1.setVisible(true);
}
}
运行时窗口打开了关不上,要在任务管理器里才能关
另外被提示
import java.util.*;
import java.math.*;
没有成功导入,是什么原因
------解决方案--------------------------------------------------------
注册一个监听器:
Main SinFrame1 = new Main ();
SinFrame1.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
另:导入的包是没有问题的。