我正在制作一个简单的老虎机,正在研究“赢钱线”,我想使用Graphics
类来画线,但是我似乎无法使这些线位于“顶部”。 JLabel
中的“”。该行将“隐藏”在标签所具有的图标后面。
对此有任何解决办法吗?
public void vinstLinje1() {
if (lblBild1.getIcon().toString().equals(lblBild4.getIcon().toString())
&& lblBild1.getIcon().toString().equals(lblBild7.getIcon().toString())) {
String vinstsumma2 = size.getSelectedItem().toString();
int vinstsumma = 0;
if (lblBild1.getIcon().toString().equals("file:/C:/Users/L%c3%a9onard/Documents/NetBeansProjects/SlotMachine/build/classes/images/ankare.png")) {
vinstsumma = Integer.parseInt(vinstsumma2) * 3;
vinst.setText("You've won: " + vinstsumma + " KR");
summa = summa + vinstsumma;
pengar.setText(Integer.toString(summa) + " KR");
} else if (lblBild1.getIcon().toString().equals("file:/C:/Users/L%c3%a9onard/Documents/NetBeansProjects/SlotMachine/build/classes/images/git.png")) {
vinstsumma = Integer.parseInt(vinstsumma2) * 5;
vinst.setText("You've won: " + vinstsumma + " KR");
summa = summa + vinstsumma;
pengar.setText(Integer.toString(summa) + " KR");
} else if (lblBild1.getIcon().toString().equals("file:/C:/Users/L%c3%a9onard/Documents/NetBeansProjects/SlotMachine/build/classes/images/hippie.png")) {
vinstsumma = Integer.parseInt(vinstsumma2) * 2;
vinst.setText("You've won: " + vinstsumma + " KR");
summa = summa + vinstsumma;
pengar.setText(Integer.toString(summa) + " KR");
}
Graphics g = this.getGraphics();
g.setColor(Color.red);
g.drawLine(25, 132, 550, 132);
}