Java编程窗口中显示图片

我想编个东西,窗口左边是textarea,右边有一个图片显示区,,图片显示区下面还有一些按钮,这个怎么实现啊???... 我想编个东西,窗口左边是textarea,右边有一个图片显示区,,图片显示区下面还有一些按钮,这个怎么实现啊??? 展开
 我来答
程序那点事
2009-03-04 · TA获得超过6140个赞
知道大有可为答主
回答量:3253
采纳率:59%
帮助的人:1298万
展开全部
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.net.*;
import java.awt.color.*;
import java.util.Vector;
public class Login extends JFrame
implements ActionListener
{
int port=3000;
static Vector v=new Vector();
private JLabel qqid;
private JLabel qqpwd;
private JTextField use;
private JPasswordField pwd;
private JButton login;
private JButton reg;
private JButton canel;
private JLabel imageLabel;
private Icon image;
JPanel pane;
public Login(String str){
super(str);
int screenWidth = (int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().width;
int screenHeight = (int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().height;
image=new ImageIcon("picture\\科比.png");
imageLabel=new JLabel(image);
imageLabel.setBounds(0,0,230,75);
this.add(imageLabel);
qqid=new JLabel("QQ号码:");
qqpwd=new JLabel("QQ密码:");
use=new JTextField();
pwd=new JPasswordField('*');
login=new JButton("登录");
reg=new JButton("注册");
canel=new JButton(" 取消");
pane=new JPanel();
pane.setLayout(null);
pane.add(qqid);
pane.add(use);
pane.add(qqpwd);
pane.add(pwd);
pane.add(canel);
pane.add(login);
pane.add(reg);
qqid.setBounds(15,80,150,20);
use.setBounds(65,80,150,20);
qqpwd.setBounds(15,115,150,20);
pwd.setBounds(65,115,150,20);
login.setBounds(10,160,60,20);
canel.setBounds(80,160,65,20);
reg.setBounds(160,160,60,20);
this.getContentPane().add(pane).setBackground(Color.white);
this.getContentPane().add(pane);
login.addActionListener(this);
reg.addActionListener(this);
canel.addActionListener(this);
this.setResizable(false);
this.setSize(245,240);
this.setLocation((screenWidth-245)/2, (screenHeight-240)/2);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e){
JButton jb=(JButton)e.getSource();
if(jb==login) {
Talk talk=new Talk();
DatagramPacket dp=null;
try{
talk.sendMSG("登录"+":"+use.getText().trim()+":"+pwd.getText().trim()+":"+port,"127.0.0.1",3001);
dp=talk.getMsg(port);
}
catch(Exception ex) {
}
String re=new String(dp.getData(),0,dp.getData().length);
if(re.trim().equals("success"))
{
this.setVisible(false);
new Chat(use.getText().trim(),"127.0.0.1","port");

}
else
JOptionPane.showMessageDialog(pane,"登录失败 请重新登录","错误",JOptionPane.INFORMATION_MESSAGE);
}else if(jb==canel){
this.setVisible(false);
}
else if(jb==reg){
new Reg();
}
}
public static void main(String args[]){
new Login("J_QQ用户登录界面");
}}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式