#I Dont know why it is not right?
1 messages ยท Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
its a poor question, not well asked
but i think they want ur MyDrawing to be added to a (existing) JFrame
not for MyDrawing to be a JFrame itself
so jframe.add(new MyDrawing()) should work
that said, funnily enough it would also work if its a jframe by itself
since one can add jframes to jframes
any component would work
??
no
everytime i reset it looks like this?
ur misunderstanding
I think the main
no
what do u need to change with the class code so that the following code would be valid and compile
JFrame frame = new JFrame();
frame.add(new MyDrawing());
lookup the doc of JFrames add method
to see what it requires
so why did mine not work?
bc that would make mydrawing a jframe by itself
but thats not the question
there is a jframe already
and they want to add ur drawing as subcomponent to it
lookup the doc of JFrames add method
to see what it requires
did u do that already?
show me a screenshot of the jframe add javadoc
Public class MyDrawing extends JFrame means the JFrame is the father class while the MyDrawing class is the son class so the point here is how to connect 2 of them at least not inside the public class MyDrawing
If they have an uml
That would better
again, all they want is that u can write
JFrame frame = new JFrame();
frame.add(new MyDrawing());
either that or they truly want u to make MyDrawing a JFrame itself (but then they worded the question really poor) but u just entered the wrong text. like perhaps u only have to enter extends JPanel instead of the full line etc
they likely do a hardcoded text check
(bc its a shitty question)
Nah that a tough question
its not. its just not well asked
yep still not getting it?
whats unclear to u? i gave u instructions
just do what i told u and we can move forward ๐
@flat flower lets not belittle people for lack of knowledge. we all started somewhere
please remain friendly, thank you
@austere ivy please do that:
lookup the doc of JFrames add method
to see what it requires
share me a screenshot of the doc for that method
and we can work from there
this
thats not the javadoc
this is the official documentation of the JFrame class
declaration: module: java.desktop, package: javax.swing, class: JFrame
if u scroll down u can find the add methods
which leads u here
declaration: module: java.desktop, package: java.awt, class: Container
so. what kind of class/type does this method expect?
add(Component comp)
yes. so which class/type does the add method expect?
Appends a specified component to a container
thats not what im asking
which class does MyDrawing need to extend from in order for someJFrame.add(new MyDrawing()) to work?
public Component add(Component comp)
i want u to give me a single word. not 5
public class MyDrawing extends public Component add(Component comp) { definitely would be wrong
so. what type exactly?
House? Ship? Dog? Person? JFrame? Picture? sth else?
JFrame?
no
look at the doc again
whats the parameter the add method expects
dont guess
u have to understand
and if sth is unclear, talk with me
dont be silent and post random stuff
add method?
is there a language barrier? i feel like ur answers make little sense to what i was asking
and u not posting entire sentences makes it hard to understand whats unclear to u and going on in ur head
i just am not sure why my answer is incorrect thats all ? why is my answer incorrect?
but do u know what a method and what a parameter is?
cause u cant answer my questions to it
lets take a look at this method:
public static void printText(String text) {
System.out.println(text);
}
whats the parameter here?
text right?
and whats its type?
public
Java AWT
no. ur massively overcomplicating this
i think
is text a Dog? is it a House? is it a Person? what is it?
look at the code ๐
public static void printText(String text) {
System.out.println(text);
}
java?
no. okay. let me approach this differently
Dog dog = new Dog();
printText(dog);
can u write that or not?
i feel a bit like u went head first into some java quiz about swing (which is a complex UI framework) without having done basics first
yes
like, u need to learn about basics of programming, if, loops, methods, classes, OOP, ... before even attempting to do any of that stuff
Is dog a String?
yes to "can u write that" or yes to "u went head first into it"?
its a bit unfortuante that u dont stick with us so we can go through this quicker. im sadly out of time for now