Display.java now extends JPanel. paintComponent() overridden.
This commit is contained in:
parent
d513d5f9fa
commit
e25cc615cd
@ -1,14 +1,18 @@
|
|||||||
package cicaprojekt;
|
package cicaprojekt;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Display {
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
public class Display extends JPanel{
|
||||||
private List<Drawer> visuals;
|
private List<Drawer> visuals;
|
||||||
|
|
||||||
public Display() {
|
public Display() {
|
||||||
visuals = new ArrayList<>();
|
visuals = new ArrayList<>();
|
||||||
|
setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addVisual(Drawer visual) {
|
public void addVisual(Drawer visual) {
|
||||||
@ -18,5 +22,14 @@ public class Display {
|
|||||||
public void drawVisuals() throws IOException {
|
public void drawVisuals() throws IOException {
|
||||||
for(Drawer visual : visuals)
|
for(Drawer visual : visuals)
|
||||||
visual.draw();
|
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