JAVA小程序中的setBackground(Color c) 你在什么什么地方使用setBackground的?在repaint中试过吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 调用setBackground(Color c)的控件的背景有可能是透明的,用setOpaque(false)设定为不透明即可。 调用setBackground(Color c)的控件的背景有可能是透明的,用setOpaque(false)设定为不透明即可。如动态的改变,同时加上this.validate();repaint(); import java.awt.*;import java.awt.event.*;import javax.swing.*;public class MyApp extends Frame{ public MyApp() { this.addWindowListener (new WindowAdapter(){ public void windowClosing(WindowEvent e){ dispose(); System.exit(0); } }); setBackground(Color.red); setLayout(new FlowLayout()); Panel p = new Panel(); TextArea ta = new TextArea(9,9); p.add(ta); ta.setText("asdf\n"+"sdddddddddddddddddddddddddddd\n"); ta.setEditable(false); // ta.setEnabled(false); add(p); } public static void main(String args[]) { System.out.println("Starting App"); MyApp f = new MyApp(); f.setSize(100,100); f.show(); }} Java项目开发全程实录,第一章的进销存程序,运行之后登陆出现问题,是什么原因? MyEclipse6.0总是意外终止 窗口中如何调用applet 请java高手解答问题? eclipse编译时的"$"问题 大家来拿分了!! 关于JUNIT的问题(快过年了,顺便散把分,祝大家新年快乐) 为什么不能执行?一个很小的JAVA测试程序 IBM WebSphere 3.5.0如何配置testapp应用程序才能运行? 请给一个随机数产生的java程序? 问大家一个绝对很菜的问题,我是新人,别见笑。 who 有java 的 源 碼
import java.awt.event.*;
import javax.swing.*;public class MyApp extends Frame
{
public MyApp()
{
this.addWindowListener (new WindowAdapter(){
public void windowClosing(WindowEvent e){
dispose();
System.exit(0);
}
});
setBackground(Color.red);
setLayout(new FlowLayout());
Panel p = new Panel();
TextArea ta = new TextArea(9,9);
p.add(ta);
ta.setText("asdf\n"+"sdddddddddddddddddddddddddddd\n");
ta.setEditable(false);
// ta.setEnabled(false);
add(p);
}
public static void main(String args[])
{
System.out.println("Starting App");
MyApp f = new MyApp();
f.setSize(100,100);
f.show(); }
}