Hi,
da ist ein kleiner, störender Bug in meinem Tool. Ich möchte fragen, warum auf dem Combobox-Popup, auf höhe der untersten Line des umgebenden Viereckes, die Linie gezeichnet wird? Ich zeichne zuerst die Linie und dann das Popup, daß mit einem klick, af die Combobox, gezeichnet wird. Das kann so eigentlch gar nicht sein!? Hier mein Code:
public static void main(final String args[]) {
new Rickenbacker();
}
}```
```import javax.swing.JFrame;
public class Rickenbacker {
private JFrame f;
public Rickenbacker() {
f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(new Test());
f.setSize(420, 315);
f.setVisible(true);
}
}```
```import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.*;
import javax.swing.*;
public class Test extends JPanel {
private static final long serialVersionUID = 1L;
private int x = 30;
private int y = 30;
private Double xx = 30.0;
private Double yy = 30.0;
private boolean shotclicked;
private GeneralPath gp;
public Test() {
addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if(e.getX()>=x+136 && e.getX()<=x+183 && e.getY()>=y+129 && e.getY()<=y+155) {
if(this.isShotclicked())
this.setShotclicked(false);
else this.setShotclicked(true);
repaint();
}
}
});
}
public void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
super.paintComponent(g2);
// Füllen des Hintergrundes mit der default color
g2.setColor(Color.BLACK);
g2.fillRect(0, 0, this.getWidth(), this.getHeight());
g2.setColor(Color.GREEN);
g2.setFont(new Font("Luicidan", Font.PLAIN, 11));
gp = new GeneralPath();
g2.drawString("Screenshots", x+99, y+121);
gp.moveTo(x+94, y+116);
gp.lineTo(x+89, y+116);
gp.lineTo(x+89, y+159);
gp.lineTo(x+193, y+159);
gp.lineTo(x+193, y+116);
gp.lineTo(x+165 , y+116);
g2.drawString("Picnr.:", x+100, y+142);
g2.drawRect(x+136, y+129, 47, 19);
gp.moveTo(x+163, y+129);
gp.lineTo(x+163, y+148);
gp.moveTo(x+168, y+138);
gp.lineTo(x+178, y+138);
gp.moveTo(x+169, y+139);
gp.lineTo(x+177, y+139);
gp.moveTo(x+170, y+140);
gp.lineTo(x+176, y+140);
gp.moveTo(x+171, y+141);
gp.lineTo(x+175, y+141);
gp.moveTo(x+172, y+142);
gp.lineTo(x+174, y+142);
gp.moveTo(x+173, y+143);
gp.lineTo(x+173, y+143);
g2.draw(gp);
g2.drawString("001", x+142, y+142);
if(this.isShotclicked()) {
g2.setColor(Color.BLACK);
g2.fillRect(x+135, y+128, 47, 120);
g2.setColor(Color.GREEN);
g2.drawRect(x+136, y+129, 47, 120);
g2.drawRect(x+136, y+129, 47, 19);
gp.moveTo(x+163, y+129);
gp.lineTo(x+163, y+148);
gp.moveTo(x+168, y+138);
gp.lineTo(x+178, y+138);
gp.moveTo(x+169, y+139);
gp.lineTo(x+177, y+139);
gp.moveTo(x+170, y+140);
gp.lineTo(x+176, y+140);
gp.moveTo(x+171, y+141);
gp.lineTo(x+175, y+141);
gp.moveTo(x+172, y+142);
gp.lineTo(x+174, y+142);
gp.moveTo(x+173, y+143);
gp.lineTo(x+173, y+143);
g2.draw(gp);
}
}
public Double getXx() {
return xx;
}
public void setXx(Double xx) {
this.xx = xx;
}
public Double getYy() {
return yy;
}
public void setYy(Double yy) {
this.yy = yy;
}
public boolean isShotclicked() {
return shotclicked;
}
public void setShotclicked(boolean shotclicked) {
this.shotclicked = shotclicked;
}
}```