package carspeedometer;
import java.awt.Graphics;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
class a1 {
a1() {
JFrame jf = new JFrame("Speedometer");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel jp = new JPanel();
JLabel jb = new JLabel(new ImageIcon(
"C:/Users/Vinayak/Desktop/tester.jpg"));
jp.add(jb);
jf.add(jp);
jf.setVisible(true);
jf.setSize(700, 700);
}
public void paint(Graphics g) {
g.drawLine(70, 70, 200, 200);
}
public static void main(String...s) {
new a1();
}
}
屏幕上没有显示线条。我想在图像顶部显示线条。请帮助。在这里,我正在尝试构建一个速度计,但首先需要显示一条线