public TilePanel(TileFrame tileFrame, TileSheet tileSheet) {
        setLayout(null);
        this.tileFrame = tileFrame;
        this.tileSheet = tileSheet;
        tileFrame.addMouseListener(new MouseInputAdapter() {
            @Override
            public void mouseClicked(MouseEvent event) {
                if (TilePanel.this.tileSheet != null) {
                    int x = 0;
                    int y = 0;
                    for (Tile tile : TilePanel.this.tileSheet.getTiles()) {
                        if (event.getXOnScreen() >= x + TilePanel.this.getLocationOnScreen().getX()
                                && event.getXOnScreen() < x + TilePanel.this.getLocationOnScreen().getX() + TilePanel.this.tileSheet.getTileWidth()
                                && event.getYOnScreen() >= y + TilePanel.this.getLocationOnScreen().getY()
                                && event.getYOnScreen() < y + TilePanel.this.getLocationOnScreen().getY() + TilePanel.this.tileSheet.getTileHeight()) {
                            tile.setSelected(true);
                        } else {
                            tile.setSelected(false);
                        }
                        x += TilePanel.this.tileSheet.getTileWidth();
                        if (x >= getWidth()) {
                            x = 0;
                            y += 16;
                        }
                    }
                    TilePanel.this.repaint();
                }
            }
        });
    }