
为什么java语言中JFrame设置了背景色却看不见,而在Frame却可以看见
packagepackBbb;importjava.awt.*;importjavax.swing.*;importjava.awt.event.*;publicclas...
package packBbb;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class app17_1
{
public static void main(String[] args)
{
JFrame frm=new JFrame("my first AWT program");
JLabel lab=new JLabel("hello java!");
frm.setSize(220,150);
frm.setBackground(Color.yellow);
frm.setLocation(250,250);
frm.add(lab);
frm.setVisible(true);
//frm.addWindowListener(new WindowAdapter(){
//public void windowClosing(WindowEvent e){System.exit(0);}});
}
}
以上程序背景色 不显示。
package packBbb;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class app17_1
{
public static void main(String[] args)
{
Frame frm=new Frame("my first AWT program");
Label lab=new Label("hello java!");
frm.setSize(220,150);
frm.setBackground(Color.yellow);
frm.setLocation(250,250);
frm.add(lab);
frm.setVisible(true);
//frm.addWindowListener(new WindowAdapter(){
//public void windowClosing(WindowEvent e){System.exit(0);}});
}
}
背景色能显示,为什么?
开发环境为eclipse,为什么没人回答呢? 展开
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class app17_1
{
public static void main(String[] args)
{
JFrame frm=new JFrame("my first AWT program");
JLabel lab=new JLabel("hello java!");
frm.setSize(220,150);
frm.setBackground(Color.yellow);
frm.setLocation(250,250);
frm.add(lab);
frm.setVisible(true);
//frm.addWindowListener(new WindowAdapter(){
//public void windowClosing(WindowEvent e){System.exit(0);}});
}
}
以上程序背景色 不显示。
package packBbb;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class app17_1
{
public static void main(String[] args)
{
Frame frm=new Frame("my first AWT program");
Label lab=new Label("hello java!");
frm.setSize(220,150);
frm.setBackground(Color.yellow);
frm.setLocation(250,250);
frm.add(lab);
frm.setVisible(true);
//frm.addWindowListener(new WindowAdapter(){
//public void windowClosing(WindowEvent e){System.exit(0);}});
}
}
背景色能显示,为什么?
开发环境为eclipse,为什么没人回答呢? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询