求一个小程序,要求:给已知图形加上不同颜色的边框(图形是用画图画出的),利用栈和链表的知识。谢谢咯
发布网友
发布时间:2022-05-15 12:42
我来回答
共3个回答
热心网友
时间:2023-10-23 22:40
import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class DrawTest {
public static int x0, y0;
public static void main(String[] args) {
final Frame f = new Frame("draw");
f.setBackground(Color.blue);
f.setLocation(300, 300);
f.setSize(400, 400);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
f.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
x0 = e.getX();
y0 = e.getY();
}
public void mouseReleased(MouseEvent e) {
try {
Graphics g = f.getGraphics();
g.setColor(Color.red);
g.drawLine(x0, y0, e.getX(), e.getY());
} catch (Exception ex) {
System.out.println(ex.toString());
}
}
});
f.show();
}
}
热心网友
时间:2023-10-23 22:41
用每天秀秀吧,这个挺好用的,下载地址百度一下:美图秀秀 第一个就是
热心网友
时间:2023-10-23 22:41
import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class DrawTest
public static int x0, y0;
public static void main(String[] args) {
final Frame f = new Frame("draw");
f.setBackground(Color.blue);
f.setLocation(300, 300);
f.setSize(400, 400);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
f.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
x0 = e.getX();
y0 = e.getY();
public void mouseReleased(MouseEvent e) {
try {
Graphics g = f.getGraphics();
g.setColor(Color.red);
g.drawLine(x0, y0, e.getX(), e.getY());
catch (Exception ex)
System.out.println(ex.toString());
f.show();