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);

}

}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值