1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
   | public class WorldListPanel extends JPanel {
 
	private TexturePaint boxBackground = null;
	private TexturePaint boxLeft = null;
	private TexturePaint boxRight = null;
	private TexturePaint boxTop = null;
	private TexturePaint boxBottom = null;
 
	public WorldListPanel() {
		super(new GridBagLayout());
 
		ResourceManager resourceManager = ResourceManager.getInstance();
 
		BufferedImage boxBackImage = resourceManager.loadImage(GUIResourcePath.WORLDLIST_BOX_BACKGROUND);
		boxBackground = new TexturePaint(
			boxBackImage,
			new Rectangle(0, 0, boxBackImage.getWidth(), boxBackImage.getHeight())
		);
		BufferedImage boxLeftImage = resourceManager.loadImage(GUIResourcePath.WORLDLIST_BOX_LEFT);
		boxLeft = new TexturePaint(
			boxLeftImage,
			new Rectangle(0, 0, boxLeftImage.getWidth(), boxLeftImage.getHeight())
		);
		BufferedImage boxRightImage = resourceManager.loadImage(GUIResourcePath.WORLDLIST_BOX_RIGHT);
		boxRight = new TexturePaint(
			boxRightImage,
			new Rectangle(0, 0, boxRightImage.getWidth(), boxRightImage.getHeight())
		);
		BufferedImage boxTopImage = resourceManager.loadImage(GUIResourcePath.WORLDLIST_BOX_TOP);
		boxTop = new TexturePaint(
			boxTopImage,
			new Rectangle(0, 0, boxTopImage.getHeight(), boxTopImage.getWidth())
		);
		BufferedImage boxBottomImage = resourceManager.loadImage(GUIResourcePath.WORLDLIST_BOX_BOTTOM);
		boxBottom = new TexturePaint(
			boxBottomImage,
			new Rectangle(0, 0, boxBottomImage.getHeight(), boxBottomImage.getWidth())
		);
 
		setPreferredSize(new Dimension(400, 500));
		setOpaque(false);
 
		add(new JButton("Charger un monde"));
	}
 
	public void paintComponent(Graphics g) {
		Graphics2D g2d = (Graphics2D) g;
 
		g2d.setPaint(boxLeft);
		g2d.fillRect(
			0,
			boxTop.getImage().getHeight(),
			boxLeft.getImage().getWidth(),
			getHeight() - (boxBottom.getImage().getHeight() * 2)
		);
 
		g2d.setPaint(boxRight);
		g2d.fillRect(
			getWidth() - boxRight.getImage().getWidth(),
			boxTop.getImage().getHeight(),
			boxRight.getImage().getWidth(),
			getHeight() - (boxTop.getImage().getHeight() * 2)
		);
 
		g2d.setPaint(boxTop);
		g2d.fillRect(
			boxLeft.getImage().getWidth(),
			0,
			getWidth() - (boxLeft.getImage().getWidth() * 2),
			boxTop.getImage().getHeight()
		);
 
		g2d.setPaint(boxBottom);
		g2d.fillRect(
			boxLeft.getImage().getWidth(),
			getHeight() - boxBottom.getImage().getHeight(),
			getWidth() - (boxLeft.getImage().getWidth() * 2),
			boxBottom.getImage().getHeight()
		);
 
		g2d.setPaint(boxBackground);
		g2d.fillRect(
			boxLeft.getImage().getWidth(),
			boxTop.getImage().getHeight(),
			getWidth() - (boxLeft.getImage().getWidth() * 2),
			getHeight() - (boxTop.getImage().getHeight() * 2)
		);
	}
} |