我用 java 写了一个 gui 程序,我的项目类型是maven。我想使用AWTUtilities
库来创建JFrame
圆角,但是当我尝试运行项目时,我接受以下错误:
- 错误:(3, 19) java: com.sun.awt 包不存在。
- 错误:(35、9)java:找不到符号符号:变量AWTUtilities位置:类Test。
代码片段:
import com.sun.awt.AWTUtilities;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RoundRectangle2D;
public class Test extends JFrame{
private static Robot robot;
public static void main(String[] args) {
try {
robot = new Robot();
} catch (AWTException e1) {
e1.printStackTrace();
}
JFrame win = new JFrame();
win.setSize(700, 100);
JPanel panel = new JPanel();
JButton button = new JButton("simulate");
final JTextField textField = new JTextField();
textField.setPreferredSize(new Dimension(600, 30));
panel.add(textField);
panel.add(button);
win.add(panel);
Shape shape = new Rectangle2D.Double(0, 0, win.getWidth(), win.getHeight());
AWTUtilities.setWindowShape(win, shape);
win.setVisible(true);
}
}
我该如何解决?