I'm attempting to make a Breakout version of java (if I go through with it) and the first issue that I encountered is that I can't change the color of the moving rectangle (you know, the thing you hit the ball with). I tried the code under Textpad on a Windows machine and that worked fine, but not under Netbeans in Linux using jdk 1.6.0_01.
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Breakout extends Applet implements MouseListener, MouseMotionListener{
int mouse_x, mouse_y;
Thread t;
public void init(){
addMouseListener(this);
addMouseMotionListener(this);
}
public void start(){
t= new Thread();
t.start();
}
public void run(){}
public void mouseClicked(MouseEvent me){ }
public void mouseEntered(MouseEvent me){ }
public void mouseExited(MouseEvent me){ }
public void mousePressed(MouseEvent me){ }
public void mouseReleased(MouseEvent me){ }
public void mouseDragged(MouseEvent me){ }
public void mouseMoved(MouseEvent me){
mouse_x = me.getX();
if(mouse_x>=400)
mouse_x=400;
repaint();
}
public void stop() {}
public void destroy(){ }
public void paint(Graphics g){
setBackground(Color.black);
setForeground(Color.white); //doesn't work
g.drawRoundRect(mouse_x, 600, 50, 20, 20, 20);
}
}
I'm wondering if it's because the Applet under Linux uses the Native l&f theme while appets under Windows uses the Windows l&f theme.
Any thoughts would be helpful!