java在一个界面绘制两张图片_java如何在一个窗体下,插入多张图片。代码如下。...

publicclassShoppetextendsJFrame{publicShoppet(){JFrameframe=newJFrame("进击的宠物店");String[]titles={"宠物名字","宠物颜色","宠物性别","宠物年龄","宠物价格","剩余数量"};O...

public class Shoppet extends JFrame {

public Shoppet(){

JFrame frame = new JFrame("进击的宠物店") ;

String[] titles = {"宠物名字","宠物颜色","宠物性别","宠物年龄","宠物价格","剩余数量"} ;

Object [][] userInfo = {

{"白猫","白色","雄性","1岁","10元","5只"} ,

{"白猫","白色","雌性","1岁","10元","5只"} ,

{"黑猫","黑色","雄性","1岁","10元","5只"} ,

} ;

JTable table = new JTable(userInfo,titles) ;

JScrollPane scr = new JScrollPane(table) ;

frame.add(scr) ;

frame.setSize(600,303) ;

frame.setLocation(500,200) ;

frame.setVisible(true) ;

frame.addWindowListener(new WindowAdapter(){

public void windowClosing(WindowEvent arg0){

System.exit(1);

}

});

JButton but=new JButton("购买");

frame.setLayout(null);

Font fnt=new Font("Serief",Font.BOLD,28);

JButton purchase = new JButton("购买");

JButton purchase1 = new JButton("购买");

JButton purchase2 = new JButton("购买");

purchase.setBounds(581,22,80,17);

purchase1.setBounds(581,38,80,17);

purchase2.setBounds(581,54,80,17);

frame.add(purchase);

frame.add(purchase1);

frame.add(purchase2);

frame.setVisible(true);

String picPath="f:"+File.separator+"mldn.gif";

Icon icon=new ImageIcon(picPath);

JLabel lab =null;

lab =new JLabel (icon,JLabel.CENTER);

lab.setBackground(Color.YELLOW);

lab.setForeground(Color.RED);

frame.add(lab);

frame.setSize(300,160);

frame.setBackground(Color.WHITE);

frame.setLocation(500,300);

frame.setVisible(true);

}

}

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值