1个回答
展开全部
import java.awt.*;
import java.util.*;
import javax.swing.*;
/**
* @author Hardneedl
*/
public class ColorApplet extends JApplet {
private final static Dimension SIZE = new Dimension(300,200);
public Dimension getSize() {return SIZE;}
public Dimension getMinimumSize() {return SIZE;}
public Dimension getPreferredSize() {return SIZE;}
private class StringCanvas extends JComponent {
private Random random = new Random(45342345L);
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics gg = g.create();
gg.setColor(Color.BLACK);
gg.fillRect(0,0,getWidth(),getHeight());
gg.setColor( new Color ( random.nextInt( Integer.MAX_VALUE )));
gg.drawString("计算机世界", 23,23);
gg.dispose();
}
}
public void init() {
super.init();
getContentPane().add(new StringCanvas(),BorderLayout.CENTER);
}
}
import java.util.*;
import javax.swing.*;
/**
* @author Hardneedl
*/
public class ColorApplet extends JApplet {
private final static Dimension SIZE = new Dimension(300,200);
public Dimension getSize() {return SIZE;}
public Dimension getMinimumSize() {return SIZE;}
public Dimension getPreferredSize() {return SIZE;}
private class StringCanvas extends JComponent {
private Random random = new Random(45342345L);
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics gg = g.create();
gg.setColor(Color.BLACK);
gg.fillRect(0,0,getWidth(),getHeight());
gg.setColor( new Color ( random.nextInt( Integer.MAX_VALUE )));
gg.drawString("计算机世界", 23,23);
gg.dispose();
}
}
public void init() {
super.init();
getContentPane().add(new StringCanvas(),BorderLayout.CENTER);
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询