比如像这样一段代码该如何运行。
public class Login extends JFrame implements ActionListener {
private static final long serialVersionUID = -8965773902056088264L;
private JPanel pnlLogin;
private JButton btnLogin, btnRegister, btnExit;
private JLabel lblServer, lblUserName, lblPassword, lblLogo;
private JTextField txtUserName, txtServer;
private JPasswordField pwdPassword;
private String strServerIp;
private Dimension scrnsize; 
public Login() {//构造登陆窗体方法
super("登录聊天室");
pnlLogin = new JPanel();
this.getContentPane().add(pnlLogin);
lblServer = new JLabel("服务器(S):");
lblUserName = new JLabel("用户名(U):");
lblPassword = new JLabel("口  令(P):");
txtServer = new JTextField(20);
txtServer.setText("172.16.17.154");
txtUserName = new JTextField(20);
pwdPassword = new JPasswordField(20);
btnLogin = new JButton("登录(L)");
btnLogin.setToolTipText("登录到服务器");
btnLogin.setMnemonic('L');
btnRegister = new JButton("注册(R)");
btnRegister.setToolTipText("注册新用户");
btnRegister.setMnemonic('R');
btnExit = new JButton("退出(X)");
btnExit.setToolTipText("退出系统");
btnExit.setMnemonic('X');
//组件的布局及其构造方法
  ……………………………… } // 构造方法结束
public static void main(String args[]) {//启动登陆窗体
new Login();}}
 //AppServer.java程序源代码
public class AppServer extends Thread {
private ServerSocket serverSocket;
private ServerFrame sFrame;
private static Vector userOnline = new Vector(1, 1);
private static Vector v = new Vector(1,1);
public AppServer() {// 创建服务器 启动服务监听1001端口
sFrame = new ServerFrame();
try {
serverSocket = new ServerSocket(1001); // 获取服务器的主机名和IP地址
InetAddress address = InetAddress.getLocalHost();
sFrame.txtServerName.setText(address.getHostName());
sFrame.txtIP.setText(address.getHostAddress());
sFrame.txtPort.setText("1001");
} catch (IOException e) {fail(e, "不能启动服务!");}
sFrame.txtStatus.setText("已启动..."); this.start(); // 启动线程 }
public static void fail(Exception e, String str) {//退出服务器
System.out.println(str + " 。" + e); }
public void run() {//监听客户的请求,当有用户请求时创建 Connection线程
try {
while (true) {// 监听并接受客户的请求
Socket client = serverSocket.accept();
new Connection(sFrame, client, userOnline, v); // 支持多线程
}} catch (IOException e) {
fail(e, "不能监听!"); }}
public static void main(String args[]) {//启动服务器
new AppServer(); } }//Chat.java源代码
public class Chat implements Serializable{
private static final long serialVersionUID = 4058485121419391969L;
public String  chatUser; //发言人用户名
public String  chatMessage; //聊天内容
public String  chatToUser;// 接受对象用户名
public String  emote; //聊天语气
public boolean whisper;// 是否私聊}  //ChatClient.java源代码
public class ChatClient {//设置服务器IP地址
public ChatClient() { }
public static void main(String args[]) {
new Login();}}//ChatRoom.java源代码
public class ChatRoom extends Thread implements ActionListener {
private JComboBox daXiaoComboBox;
private JComboBox yangShiComboBox;
private JComboBox zitiComboBox;
private JComboBox emote;
static JFrame frmChat;
……………………
public ChatRoom(String name, String ip) {// 构造方法
String list[] = { "所有人" };
btnCls = new JButton("清屏(C)");
btnExit = new JButton("退出(X)");
 
btnSend = new JButton("发送(N)");
btnSave = new JButton("保存(S)");
btnTimer = new JButton("时钟(T)");
btnBfmusic=new JButton("播放");
btnXhmusic=new JButton("循环");
btnTzmusic=new JButton("停止");
lblUserList = new JLabel("【在线用户列表】");
lblUserMessage = new JLabel("【聊天信息】");
lblSendMessage = new JLabel("聊天内容:");
lblChatUser = new JLabel("你对:");
lblUserTotal = new JLabel("在线人数:");
chPrivateChat = new JCheckBox("私聊");
………………………………
public static void main(String args[]) {
new ChatRoom("测试用户", "172.31.5.1"); }}// Register.java主要源代码
public class Register extends JFrame  implements ActionListener
{ private JComboBox comboBox;
private static final long serialVersionUID = 9019746127517522180L;
……………………
     public Register(String ip){//构造方法
super("聊天室注册窗口");
strServerIp=ip;
pnlRegister=new JPanel();
this.getContentPane().add(pnlRegister);
lblUserName=new JLabel("用 户 名:");
lblGender=new JLabel("性    别:");
lblAge=new JLabel("年    龄:");
lblPassword=new JLabel("口    令:");
lblConfirmPass=new JLabel("确认口令:");
lblEmail=new JLabel("电子邮件:");
rbtnMale=new JRadioButton("男",true);
rbtnFemale=new JRadioButton("女");
    btngGender=new ButtonGroup();
    btnOk=new JButton("确定(O)");
    btnOk.setMnemonic('O');
    btnOk.setToolTipText("保存注册信息");
btnCancel=new JButton("返回(B)");
btnCancel.setMnemonic('B');
btnCancel.setToolTipText("返回登录窗口");
btnClear=new JButton("清空(L)");
btnClear.setMnemonic('L');
btnClear.setToolTipText("清空注册信息");
public static void main(String args[])
{ new Register("172.31.5.1"); }}  

解决方案 »

  1.   

    哪个类有main方法,就执行哪个类了。
      

  2.   

    Login login=new Login();
    login.setVisable(true);
    AppServer app=new AppServer();
    app.seart();还有几个类!你new一下 试试
      

  3.   

    javac Login.java// 编译
    java  Login// 运行
      

  4.   

    看到那个
    public static void main(String args[]) {//启动登陆窗体
    new Login();
    }

    这个方法在哪个类里面就在那个类里面点击右键->run as->java application 这样就能运行了。
      

  5.   

    一句话JFrame没有setVisible(true);对不对呢  lz