import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TankBattle
{
public static void main (String[] args)
{
new tMap("坦克大战");
}
}
class tMap extends JFrame
{
tMap(String title)
{
super(title);
setBounds(100,100,600,450);
setVisible(true);
}
public void paint(Graphics g)
{
g.drawRect(100,100,300,300);
}
}编译都正常,但运行时窗体是半透明的?求各位大侠帮小弟解决吧,实在没办法了!
import java.awt.event.*;
import javax.swing.*;
public class TankBattle
{
public static void main (String[] args)
{
new tMap("坦克大战");
}
}
class tMap extends JFrame
{
tMap(String title)
{
super(title);
setBounds(100,100,600,450);
setVisible(true);
}
public void paint(Graphics g)
{
g.drawRect(100,100,300,300);
}
}编译都正常,但运行时窗体是半透明的?求各位大侠帮小弟解决吧,实在没办法了!
{
super(title);
setBounds(100,100,600,450);
setVisible(true);
} 改为:
tMap(String title)
{
super(title);
setBounds(100,100,600,450);
this.setBackground(Color.BLACK);
setVisible(true);
}就不是半透明的了。
{
g.drawRect(100,100,300,300);
}
先調用一下super.paint(g);