Display.java now extends JPanel. paintComponent() overridden.
This commit is contained in:
parent
d513d5f9fa
commit
e25cc615cd
@ -1,14 +1,18 @@
|
||||
package cicaprojekt;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Display {
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class Display extends JPanel{
|
||||
private List<Drawer> visuals;
|
||||
|
||||
public Display() {
|
||||
visuals = new ArrayList<>();
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
public void addVisual(Drawer visual) {
|
||||
@ -18,5 +22,14 @@ public class Display {
|
||||
public void drawVisuals() throws IOException {
|
||||
for(Drawer visual : visuals)
|
||||
visual.draw();
|
||||
repaint();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
for(Drawer visual : visuals)
|
||||
g.drawImage(visual.getImage(), visual.getTileX() * 64, visual.getTileY() * 64, null);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user