日期:2014-05-20 浏览次数:20872 次
package org.zhangming.swing;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class TestBackImage extends JFrame
{
private JButton button1,button2,button3;
private JTextField text;
private JTextArea area;
private ImageIcon icon;
private JPanel panelS,panelN;
private JLabel backLabel;
TestBackImage()
{
button1=new JButton("文件传输");
button2=new JButton("图片发送");
button3=new JButton("视频会话");
text = new JTextField(20);
area = new JTextArea(15,20);
button1.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e)
{
area.setText(area.getText() + "\n" +text.getText());
text.setText("");
}
});
icon = new ImageIcon("e:/Tulips.jpg");
backLabel = new JLabel(icon);
backLabel.setSize(280,380);
icon.setImage(icon.getImage().getScaledInstance(280,380,Image.SCALE_DEFAULT));
panelS = new JPanel();
panelN = new JPanel();
panelN.setLayout(new FlowLayout());
panelN.add(button1);
panelN.add(button2);