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(); }} 为什么 package 一定要写在 import 前面 急!!关于获得JTable中的值 大家帮帮忙 关于如何向JComboBox添加选项 一个关于tableColumn(SWT)的问题 大问题请教 !!!main 方法问题!!! 一秒钟解决的问题,大家不妨来看看 Frame的嵌套怎么搞? 英雄在哪儿?请问如何让WEBLOGIC6.1自带的例子程序跑起来??? 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(); }
}