Forums Register Login

how to change a JFrame class to non GUI

+Pie Number of slices to send: Send
Hello
my first steps with java architecture ;)


i want to rewrite a GUI application of a game client who is declared like this:


My first goal is to run an application without all the GUI stuff so i made it:


is this okay like that ?

what i wanna do later is to use this class every time when a player is missing playing randomly.

comments welcome

dirk
1
+Pie Number of slices to send: Send
You should only extend the Thread class if you want to alter the functionality of a thread. If you just want a class that can be run in a separate thread, you should implement the Runnable interface instead.
+Pie Number of slices to send: Send
You can't just go replacing classes with other classes.
You rarely ever need to extend Thread and it's unlikely that you need to do so in your scenario.
Why do you need to rewrite this code in the first place?
+Pie Number of slices to send: Send
 

E Armitage wrote:

Why do you need to rewrite this code in the first place?



As i wrote i wanna have an aplication without GUI, because the GUI is a gameclient showing game cards and so on, the Randomplayer should act randomly like the GUIclient but not showing anything

also i want in later steps taking this code over to the serverside so a new thread ist started everytime a player is missing ( the randomplayer will be replacable by other strategies i.e MCTS implementation)
+Pie Number of slices to send: Send
 

Adrian Burkett wrote:You should only extend the Thread class if you want to alter the functionality of a thread. If you just want a class that can be run in a separate thread, you should implement the Runnable interface instead.



isnt it a problem that i need to implement Observer also ? Can i implement runnable in addition ? and how ?
1
+Pie Number of slices to send: Send
 

dirk dj jaeckel wrote:

Adrian Burkett wrote:You should only extend the Thread class if you want to alter the functionality of a thread. If you just want a class that can be run in a separate thread, you should implement the Runnable interface instead.



isnt it a problem that i need to implement Observer also ? Can i implement runnable in addition ? and how ?



A class can only extend one other class. It can implement as many interfaces as you want.
+Pie Number of slices to send: Send
 

dirk dj jaeckel wrote:

Adrian Burkett wrote:You should only extend the Thread class if you want to alter the functionality of a thread. If you just want a class that can be run in a separate thread, you should implement the Runnable interface instead.



isnt it a problem that i need to implement Observer also ? Can i implement runnable in addition ? and how ?


If you are asking these questions then you really shouldn't be trying to read GUI code at all or worse trying to automagically transform it to an equivalent non gui app.
Better start by reading and understanding these basics. Otherwise there are lots of things you are going to omit/miss from the original code.
+Pie Number of slices to send: Send
 

E Armitage wrote:
If you are asking these questions then you really shouldn't be trying to read GUI code at all or worse trying to automagically transform it to an equivalent non gui app.
Better start by reading and understanding these basics. Otherwise there are lots of things you are going to omit/miss from the original code.




Some men have no choice ...
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 549 times.
Similar Threads
invalid method declaration; return type required
Questin on listeners
My JFrame pops up inside a regular windows window??
Making instantiated frames independent
interface again
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:26:06.