java怎么给窗口加图片不显示不出来_我想在这面板上添加图片,可是图片显示不出来,求助~...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

public class FlowLayoutDemo extends JFrame implements ActionListener{

private JButton button1,button2,button3;

JButton button4;

private Container container;

private FlowLayout layout;

public FlowLayoutDemo(){

super("请选择你要查看的信息");

layout =new FlowLayout();

container =getContentPane();

container.setLayout(layout);

JButton button1=new JButton("成绩");

add(button1);

button1.setPreferredSize(new Dimension(70,45));

JButton button2=new JButton("个人信息");

add(button2);

button2.setPreferredSize(new Dimension(90,45));

JButton button3=new JButton("课程表");

add(button3);

button3.setPreferredSize(new Dimension(80,45));

JButton button4=new JButton("退出");

add(button4);

button4.setPreferredSize(new Dimension(80,45));

button4.addActionListener(this);

JPanel p=new JPanel();

JLabel lblImage = new JLabel(new ImageIcon("image/us.gif"));

lblImage.setBounds(10999, 199990,50, 60);

p.add(lblImage); //放置这个

setSize(500,150);

Toolkit tk = Toolkit.getDefaultToolkit();

setLocation((tk.getScreenSize().height - this.HEIGHT)/2, (tk.getScreenSize().width - this.WIDTH)/10);

setVisible(true);

button1.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e) {

setVisble(false);

SplitDemo application= new SplitDemo();

}});

button2.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e) {

setVisble(false);

TableDemo applet=new TableDemo();

JFrame aFrame=new JFrame("信计102班个人基本信息");

aFrame.getContentPane().add(applet,BorderLayout.CENTER);

aFrame.setSize(1000,500);

applet.init();

applet.start();

aFrame.setVisible(true);

}});

button3.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e) {

setVisble(false);

y applet=new y();

JFrame aFrame=new JFrame("2010-2011年度信计102班课程表");

aFrame.getContentPane().add(applet,BorderLayout.CENTER);

aFrame.setSize(1000,300);

applet.init();

applet.start();

aFrame.setVisible(true); }});}

public void actionPerformed(ActionEvent e) {

if(e.getSource()==button4);

System.exit(0);

}

private void setVisble(boolean b) {}

public static void main(String[] args){

FlowLayoutDemo application =new FlowLayoutDemo();

application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

}

本文链接:https://my.lmcjl.com/post/19967.html

展开阅读全文

4 评论

留下您的评论.