#Should I keep code to one script or use multiple interfaces to keep organized?
1 messages · Page 1 of 1 (latest)
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
Let me explain specifically
I have a class and an interface
The class extends the interface
I have defined a method in the interface with a return put into it so as I call the specific method it should come out with a certain variable
Problem is, I have ran into the problem of eventhandling, to which I may be going off of the right track
// This is simplified
interface thisinterface {
default Pane thispane() {
Pane apane = new Pane(); // A Pane
Button foo = new Button();
// Variables defined for both of these to then come to the return statement
return apane;
}
}
Detected code, here are some useful tools:
// This is simplified
interface thisinterface {
default Pane thispane() {
Pane apane = new Pane();
// A Pane
Button foo = new Button();
// Variables defined for both of these to then come to the return statement
return apane;
}
}
class thisclass implements thisinterface {
Parent thisparent {
// All that stuff...
}
@Override
public void start(Stage stage) throws Exception {
stage.setScene(new Scene(apane(), 300, 300));
stage.show();
}
public static void main(String[] args) {
launch(args);
}
} ```
Detected code, here are some useful tools:
class thisclass implements thisinterface {
Parent thisparent {
// All that stuff...
}
@Override
public void start(Stage stage) throws Exception {
stage.setScene(new Scene(apane(), 300, 300));
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Now I come into the problem
I need to use apane which is fine
But I also have the button
I need to use an eventhandler
why not use an abstract class instead?
can you extend multiple of those?
no
Well, the structure of my program uses multiple of these panes
I wanted to organize them into the interfaces
Fine, a simple solution would be to instead of returning Pane return a container class that has a reference to Pane Button etc.
You shouldn't really be using default methods
I should've looked it up
Ok will try
Does it being a simple solution affect anything?