Topic: sos-更改那些代码可以只在原窗体显示图片 |
Print this page |
1.sos-更改那些代码可以只在原窗体显示图片 | Copy to clipboard |
Posted by: mmqq Posted on: 2006-06-08 08:20 import java.awt.*; import java.awt.event.*; import javax.swing.*; public class jb{ public static void main(String args[]){ JFrame f=new JFrame("按钮事件"); Container contentPane=f.getContentPane(); contentPane.setLayout(new GridLayout(1,2)); Icon icon=new ImageIcon(".\\66.jpg"); JLabel label2=new JLabel("a",icon,JLabel.CENTER); label2.setHorizontalTextPosition(JLabel.CENTER); contentPane.setLayout(new FlowLayout( FlowLayout.CENTER,10,10)); JButton bb=new JButton("图片"); bb.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ JFrame bf=new JFrame("新窗体"); Icon icon=new ImageIcon(".\\56.jpg"); JLabel label2=new JLabel(icon); bf.getContentPane().add(label2); bf.setSize(300,360); bf.show(); }}); contentPane.add(label2); contentPane.add(bb); f.pack(); f.show(); }} |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |