| | |
Assignment = Chat Window. . Urgent!
![]() |
Hello Fellas,
I would like to ask some help from you.
I'm Mark from the Philippines.
I'm a newbie programmer and I'm new with java,that's why it's very difficult for me to make a program using java.
Our Teacher had given us an assignment using java,to make a simple chat window within one week. And that day is on friday,but still I'm not finished doing it.
one text field,one text area,three buttons(Send=to send the text in the text area,Clear=to clear out the text in the text area,Cancel=to cancel the text in the text field). .
Here is my code.
I'm waiting for your positive response.
GodBlesS yAh All!
I would like to ask some help from you.
I'm Mark from the Philippines.
I'm a newbie programmer and I'm new with java,that's why it's very difficult for me to make a program using java.
Our Teacher had given us an assignment using java,to make a simple chat window within one week. And that day is on friday,but still I'm not finished doing it.
one text field,one text area,three buttons(Send=to send the text in the text area,Clear=to clear out the text in the text area,Cancel=to cancel the text in the text field). .
Here is my code.
Java Syntax (Toggle Plain Text)
import java.awt.*; import java.awt.event.*; import java.awt.event.ItemEvent.*; public class cwindow implements ActionListener, ItemListener { private Frame frame; private MenuBar menbar; private Menu men1; private Menu men2; private Menu men3; private MenuItem meni1; private MenuItem meni2; private MenuItem meni3; private MenuItem meni4; private CheckboxMenuItem meni5; private TextArea txta; private Button send = new Button("Send"); private Button clear = new Button("Clear"); private Button cancel = new Button("Cancel"); private TextField marky; public void go() { frame = new Frame("chat event"); menbar = new MenuBar(); txta = new TextArea(" ", 4, 20); send.addActionListener(this); frame.add(txta, BorderLayout.CENTER); marky = new TextField(" ", 25); frame.add(send,BorderLayout.EAST); marky.addKeyListener( new NameHandler() ); frame.add(marky, BorderLayout.SOUTH); men1 = new Menu("File"); men2 = new Menu("Edit"); men3 = new Menu("Help"); menbar.add(men1); menbar.add(men2); menbar.setHelpMenu(men3); frame.setMenuBar(menbar); meni1 = new MenuItem("New"); meni2 = new MenuItem("Save"); meni3 = new MenuItem("Load"); meni4 = new MenuItem("Quit"); meni1.addActionListener(this); meni2.addActionListener(this); meni3.addActionListener(this); meni4.addActionListener(this); men1.add(meni1); men1.add(meni2); men1.add(meni3); men1.addSeparator(); men1.add(meni4); meni5 = new CheckboxMenuItem("Persistent"); meni5.addItemListener(this); men1.add(meni5); frame.setSize(200,200); frame.pack(); frame.setVisible(true); } public void actionPerformed( ActionEvent ae) { System.out.println("Button \"" + ae.getActionCommand() + "\" Pressed."); if (ae.getActionCommand().equals("Quit")) { System.exit(0); } } public void itemStateChanged(ItemEvent ie) { String state = "Deselected"; if (ie.getStateChange() == ItemEvent.SELECTED) { state = "Selected"; } System.out.println(ie.getItem() + " " + state); } class NameHandler extends KeyAdapter { public void keyPressed(KeyEvent e) { char c = e.getKeyChar(); if ( Character.isDigit(c)) { e.consume(); } } } public static void main (String args[]) { cwindow markyMenu = new cwindow(); markyMenu.go(); } }
I'm waiting for your positive response.
GodBlesS yAh All!
"Doing your BEST is better than being the BEST!"
Sometimes, the more you become educated the more you become Simple & Humble.
campuzcraze_4lyf@yahoo.com
Sometimes, the more you become educated the more you become Simple & Humble.
campuzcraze_4lyf@yahoo.com
I will be very positive when I tell you that we are not just going to do it for you.
Tell us exactly what problem you are having and we will help you correct it, otherwise, http://www.rentacoder.com/
Tell us exactly what problem you are having and we will help you correct it, otherwise, http://www.rentacoder.com/
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
•
•
Maybe I don't understand what a chat window is, but don't you have to connect to another machine in order to chat with someone? I don't see code involving Sockets anywhere. . ?
if so, all he needs to do is
String b = textArea.getText();
b += newText;
textArea.setText(b);
(or something like that
) ![]() |
Other Threads in the Java Forum
- Previous Thread: Help with java code, its urgent!!
- Next Thread: Anyway to shorten this code?
| Thread Tools | Search this Thread |
2dgraphics account android api apple applet application arguments array arrays automation banking binary binarytree bluetooth chat chatprogramusingobjects class client code color component count database derby design eclipse eclipsedevelopment encryption error fractal game givemetehcodez graphics gridlayout gui homework html ide if_statement image integer interface j2me java javadesktopapplications javaprojects jlabel jni jpanel julia keyword linux list macintosh map method methods midlethttpconnection mobile netbeans newbie nullpointerexception object open-source os problem producer program programming project projectideas property read recursion reference replaysolutions ria scanner search server set size sms sort sourcelabs splash sql sqlite stop string swing testautomation threads transforms tree ui unicode validation windows






