Hi guys,
first, i'm not the best english speaker and -writer. Therefore i ask you to apologize my language mistakes
Problably in your eyes, i have a very simply problem, but i cant add the background function to Brandonio's Snake Project. I want to have a black background in the applet. After this, i want to change the color of the grid to white.
I try to add two JPanel's to snakeApplet.java. But is it still not working. Every time i started the Applet, the background is white.
In addition, i want to add music to the applet. The music should instantly playing if the applet is open.
If the idea of the black background and white grid is not to be a looker, than i would to add a picture in the background of the grid.
But i dont know how i can code it.
I hope someone can help me please
Yours sincerley
Kevin
Edit: Kevin is only a nickname
first, i'm not the best english speaker and -writer. Therefore i ask you to apologize my language mistakes
Problably in your eyes, i have a very simply problem, but i cant add the background function to Brandonio's Snake Project. I want to have a black background in the applet. After this, i want to change the color of the grid to white.
I try to add two JPanel's to snakeApplet.java. But is it still not working. Every time i started the Applet, the background is white.
Code:
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JPanel;
public class snakeApplet extends Applet{
private snakeCanvas c;
JPanel jp1 = new JPanel();
JPanel jp2 = new JPanel();
public void init()
{
jp1.setBackground(Color.BLACK);
add(jp1);
jp2.setBackground(Color.BLACK);
add(jp2, BorderLayout.SOUTH);
c = new snakeCanvas();
c.setSize(new Dimension(640, 480));
c.setPreferredSize(new Dimension(640, 480));
c.setVisible(true);
c.setFocusable(true);
this.add(c);
this.setVisible(true);
this.setSize(new Dimension(640, 480));
}
public void paint(Graphics g)
{
this.setSize(new Dimension(640, 480));
}
}
If the idea of the black background and white grid is not to be a looker, than i would to add a picture in the background of the grid.
But i dont know how i can code it.
I hope someone can help me please
Yours sincerley
Kevin
Edit: Kevin is only a nickname