java网页插入背景图片代码_这个是java的界面代码 怎么插入背景图片 帮个忙啊 大神们...

importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;publicclassBuju2extendsJFrameimplementsActionListener{JButtonjb1=newJButton("你");JButtonjb2=newJButt...

import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class Buju2 extends JFrame implements ActionListener { JButton jb1=new JButton("你"); JButton jb2=new JButton("是"); JButton jb3=new JButton("坏"); JButton jb4=new JButton("蛋"); JLabel jl=new JLabel("白痴"); Image i=this.getToolkit().getImage("C:\\Windows\\Web\\Wallpaper\\Windows\\img0.jpg"); //你的图片路径 JPanel jp=new JPanel(); public Buju2(){ jl.setVerticalAlignment(JLabel.CENTER); jl.setHorizontalAlignment(JLabel.CENTER); this.setTitle("好蛋疼"); jp.setLayout(new BorderLayout()); jb1.addActionListener(this); jb2.addActionListener(this); jb3.addActionListener(this); jb4.addActionListener(this); jp.add(jb1,BorderLayout.NORTH); jp.add(jb2,BorderLayout.SOUTH); jp.add(jb3,BorderLayout.EAST); jp.add(jb4,BorderLayout.WEST); jp.add(jl,BorderLayout.CENTER); this.add(jp); this.setBounds(300,250,300,200); this.setVisible(true); } public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if(e.getSource()==jb1){ jl.setText("你"); } else if(e.getSource()==jb2){ jl.setText("是"); } else if(e.getSource()==jb3){ jl.setText("坏"); } else if(e.getSource()==jb4){ jl.setText("蛋"); } } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Buju2 b=new Buju2(); } }

展开

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值