aimladen's chatroom as an app menu

User Tag List

Results 1 to 1 of 1
  1. #1
    OooO's Avatar Member
    Reputation
    1
    Join Date
    May 2008
    Posts
    1
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    aimladen's chatroom as an app

    Hi

    'm new 2 this language .. going 2 write my own game .. hopefully

    so i messed around with his code a bit 2 let it work as an app

    it works in netbeans .. but not in an firefox window maybe someone could explain 2 me why

    the code:

    Code:
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.*;
    import java.net.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    
    public class Oo extends JApplet implements ActionListener
    {
    	public int port;
    	public String host;
    	public String msg;
    	public PrintWriter out;
    	public BufferedReader in;
    	public JTextArea messages;
    	public JPanel displayPanel, sendPanel;
    	public JFrame main;
    	public JScrollPane messagePane;
    	public JTextField sendM;
    	public JButton send;
    
        @Override
        public void init() {
                    Thread t = new Thread(new Runnable()
    			{
    
    		public void run()
    				{
                        try {
                        displayMsg("You are now connected to host: " + host);
                        chooseNick();
                        String msg2 = null;
                        msg2 = in.readLine();
                        while (msg2 != null) {
                            displayMsg(msg2);
                            msg2 = in.readLine();
                        }
                        } catch (IOException ex) {
                        Logger.getLogger(Oo.class.getName()).log(Level.SEVERE, null, ex);
                    }
                                            }
    				
    
    
    			});
    			t.start();
        }
           
        
    	public Oo()
    	{
    		try {
    			host = JOptionPane.showInputDialog("Enter the host name of the server.");
    			port = Integer.parseInt(JOptionPane.showInputDialog("Enter the port #"));
    			Socket connection = new Socket(host, port);
    			System.out.println("Now connected to " + host + ".");
    			out = new PrintWriter(connection.getOutputStream(), true);
    			in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    			
    		} catch(Exception e) { e.printStackTrace(); }
    
    
    		displayPanel = new JPanel();
    
    		messages = new JTextArea(20,35);
    		messages.setEditable(false);
    		messagePane = new JScrollPane(messages);
    		displayPanel.add(messagePane);
    
    		sendM = new JTextField(18);
    		sendM.addKeyListener(new KeyListenerImpl());
    
    		send = new JButton("Send");
    		send.addActionListener(this);
    
    		sendPanel = new JPanel();
    		sendPanel.add(sendM);
    		sendPanel.add(send);
    
    		getContentPane().add(displayPanel,BorderLayout.NORTH);
    		getContentPane().add(sendPanel,BorderLayout.SOUTH);
    
    		setVisible(true);
    		sendM.requestFocusInWindow();
    	}
    
    	public void actionPerformed(ActionEvent e)
    	{
    		if(e.getSource() == send)
    		{
    			out.println(sendM.getText());
    			sendM.setText("");
    		}
    		sendM.requestFocusInWindow();
    	}
    
    	public void displayMsg(String themsg)
    	{
    		messages.append("\n" +themsg);
    	}
    
    	public void chooseNick()
    	{
    		String k = JOptionPane.showInputDialog("Choose a nickname.");
    		out.println("/nick " + k);
    	}
    
        private class KeyListenerImpl implements KeyListener {
    
            public KeyListenerImpl() {
            }
    
            public void keyPressed(KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                    send.doClick();
                }
            }
    
            public void keyReleased(KeyEvent e) {
            }
    
            public void keyTyped(KeyEvent e) {
            }
        }
    }
    thx aimladen for the source code

    yours OooO

    aimladen's chatroom as an app

Similar Threads

  1. How do you fix "The app failed to initialize properly(0xc0150002)"?
    By explode13 in forum World of Warcraft Emulator Servers
    Replies: 1
    Last Post: 08-30-2007, 07:34 PM
  2. [APP]1-60 Helper
    By Dimmy353 in forum World of Warcraft Bots and Programs
    Replies: 18
    Last Post: 07-30-2007, 10:53 AM
  3. need new p2p app
    By littledeath in forum Community Chat
    Replies: 15
    Last Post: 07-26-2007, 01:28 PM
  4. [APP]Mangos Commands Handler
    By Dimmy353 in forum World of Warcraft Bots and Programs
    Replies: 8
    Last Post: 07-10-2007, 09:13 PM
  5. Jump to any height (without any 3rd part apps) MASSIVE Exploit!
    By Matt in forum World of Warcraft Exploits
    Replies: 17
    Last Post: 03-27-2006, 09:53 PM
All times are GMT -5. The time now is 05:12 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search