Magazine
 

Tips & Tricks

 

public static void main(String[] args){
new Login();
}
public Login(){
frame1 = new JFrame(“Login Page”);
tf=new JTextField();
button=new JButton(“Login”);
heading=new JLabel(“Chat Server”);
heading.setFont(new Font(“Impact”,
Font.BOLD,40));
label=new JLabel(“Enter you Login Name”);
label.setFont(new Font(“Serif”, Font.PLAIN,
24));
JPanel panel = new JPanel();
button.addActionListener(this);
panel.add(heading);panel.add(tf);panel.add(label);
panel.add(button);
heading.setBounds(30,20,280,80);
label.setBounds(20,100,250,60);
tf.setBounds(50,150,150,30);
button.setBounds(70,200,90,30);
frame1.add(panel);
panel.setLayout(null);
frame1.setSize(300, 300);
frame1.setVisible(true);
frame1.setDefaultCloseOperation
(JFrame.EXIT_ON_CLOSE);
}
// pass the user name to MyClient class
public void actionPerformed(ActionEvent e){
String name=””;
try{
name=tf.getText();
frame1.dispose();
MyClient mc=new MyClient(name);
}catch (IOException te){}
}
}

 

MyClient.java

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.ArrayList;
import java.util.Iterator;
public class MyClient extends WindowAdapter
implements ActionListener{
JFrame frame;
JList list;
JList list1;
JTextField tf;
DefaultListModel model;
DefaultListModel model1;
JButton button;
JButton lout;
JScrollPane scrollpane;
JScrollPane scrollpane1;
JLabel label;
Socket s,s1,s2;
DataInputStream din;
DataOutputStream dout;
DataOutputStream dlout;
DataOutputStream dout1;
DataInputStream din1;
String name;

Nov 2007 | Java Jazz Up |61
previous
index
next
 
View All Topics
All Pages of this Issue
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69   Download PDF