public void addNotify() {
   super.addNotify();
   Art.init(getGraphicsConfiguration());
   levelRenderer =
       new LevelRenderer(level, getGraphicsConfiguration(), level.width * 16, level.height * 16);
   levelRenderer.renderBehaviors = true;
 }
 public void paintComponent(Graphics g) {
   g.setColor(new Color(0x8090ff));
   g.fillRect(0, 0, level.width * 16, level.height * 16);
   levelRenderer.render(g, 0, 0);
   g.setColor(Color.BLACK);
   g.drawRect(xTile * 16 - 1, yTile * 16 - 1, 17, 17);
 }
  public void mouseDragged(MouseEvent e) {
    xTile = e.getX() / 16;
    yTile = e.getY() / 16;

    level.setBlock(xTile, yTile, tilePicker.pickedTile);
    levelRenderer.repaint(xTile - 1, yTile - 1, 3, 3);

    repaint();
  }
 public void setLevel(Level level) {
   this.level = level;
   Dimension size = new Dimension(level.width * 16, level.height * 16);
   setPreferredSize(size);
   setMinimumSize(size);
   setMaximumSize(size);
   repaint();
   levelRenderer.setLevel(level);
 }
  public void mousePressed(MouseEvent e) {
    xTile = e.getX() / 16;
    yTile = e.getY() / 16;

    if (e.getButton() == 3) {
      tilePicker.setPickedTile(level.getBlock(xTile, yTile));
    } else {
      level.setBlock(xTile, yTile, tilePicker.pickedTile);
      levelRenderer.repaint(xTile - 1, yTile - 1, 3, 3);

      repaint();
    }
  }