Andy Rayner

Ranch Hand
+ Follow
since Dec 09, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Andy Rayner

No, would this be a problem..

On my GUI i have some buttons one is connect and one is disconnect

When i click connect it opens up a new smaller gui
this has two textfields and an ok and cancel button.

My Main Gui and the connectGUI (as i call the method) are in the same class (ViewClass) so when i click connect

it is using the same GUI everytime. Would it probably work if the gui was in a seperate class and i create a new one everytime?
well p is blank
it is like nothing is been picked up
in the code i have to initialise the varibles
String p = "";
and portNo = 0;

and that is whats been returned after i try to do the parseint and get the text, it is as if it wont pick up the text in the fields, the same thing happens for my method getHost();
I have amended my code to this:


the first time i start the program and connect it prints out the correct port 23, the second time i get This is not a number and a 0, which obviously then throws an IOException error when it trys to connect the socket, its just wierd how im putting a number in and its not parsing one properly
I understand what your saying, when the threads are running after the event has been activated, the textfields hostname and port may have been changed and modified.

What i dont understand is why when i put my hostname and port in the first time and click ok it connects, but when i disconnect and try and do it again, it then gives me a numberformat exception.

Do you know what the best way would be to solve this, i have tried setting the fields to "" after i establish the first connection.


all this does is get the text from the JTextBox called port and converts it into an int. the method is then used to set the port when i create a new socket.
Hello i have wrote a client to connect to a MUD server and the only problem i am getting is when i disconnect i cannot reconnect again without shutting down the client and running it again

when i close the server i do this:


setText just sets the text in my JTextAre, sock.close closes my socket to the server

output is my output from the server class which is a thread
here is the code

this loop is in my run() method, getBoolean returns the boolean which i set from the setBoolean method back in the other class

this is the error i get when i try to reconnect
Exception occurred during event dispatching:
java.lang.NumberFormatException:
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at ViewClass.getPort(ViewClass.java:216)
at Controller.actionPerformed(Controller.java:28)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

any help would be appreciated
thank you
Thanks so much
17 years ago
hello when i add something to a textarea with the append() method it doesnt scroll down i have to keep scrolling down, is there a property i need to set?

Regards
Andy
17 years ago

Originally posted by David Dickinson:
[QB]
Is that correct? Does anyone have a small project they could post which utlises GUI's and MVC?

/QB]



I have a simple one called flipper, i have put it up on my webspace so you can download it and take a look, its uses a GUI, MVC and Observer/Observable



Flipper

just incase you are still wondering
17 years ago
Hello im having a few problems using the Observer Observable,
I have these classes so far

Model - kicks off two threads for input and output
Input - input from the keyboard
Output - output from the server
ViewClass - the GUI

at the moment in the output i use a bufferreader which gets each character the server gives and outputs it to the terminal, i am wanting to display this in a JTextArea using the observable
so i do this in the Output class


c is a char which holds a character representation of the int fromServer.read() //from server been the bufferreader
i then convert the char into a string and send it to a method in the Model(m) called set text.

in the model i have


for some reason i am getting this error message

----jGRASP exec: java Harness

java.lang.NoSuchMethodError
at OutputStream.run(OutputStream.java:37)

----jGRASP: operation complete.

Hope you can help me with this
many thanks again
Andy
17 years ago
thank you i got it working *smiles*
thank you how would i account for /n and /r also in the if statment, if i wanted to get all the characters that were letters digits, carriage returns
17 years ago
oh i forgot, fromServer is a bufferReader and im trying to display the output from a telnet server.

Cheers
17 years ago
This is probably very simple
i have:



and i get the error
OutputStream.java:35: char cannot be dereferenced

anyone know why
regards
17 years ago
I have taken that out and i now have


i dont know what i am doing wrong but i am not getting any response from the server when i type in, it is like the threads hang, are they synchronised properly?