再描画中に複数の線を描画する際に問題が発生します。コードは次のとおりです。
public void paintComponent(Graphics g){
Graphics2D g2d = (Graphics2D) g;
Map<Device, Device> devMap = matchEncDec();
if(devMap != null){
Iterator<?> it = devMap.entrySet().iterator();
while(it.hasNext()){
Map.Entry<Device, Device> pair = (Entry<Device, Device>) it.next();
it.remove();
g2d.setColor(Color.BLUE);
g2d.drawLine(pair.getKey().getLocationOnScreen().x + 150, pair.getKey().getLocationOnScreen().y,
pair.getValue().getLocationOnScreen().x + 150, pair.getValue().getLocationOnScreen().y);
g2d.drawLine(50, 50, 500, 550);
}
}
}
HashMapの最後のペアと追加したテストラインに対してのみ線を描画します。助けてくれてありがとう。