#I Dont know why it is not right?

1 messages ยท Page 1 of 1 (latest)

austere ivy
#

my answer is : public class MyDrawing extends JPanel {
Still is wrong why?

keen finchBOT
#

<@&987246399047479336> please have a look, thanks.

austere ivy
#

public class MyDrawing extends JPanel {
not this?

lilac willow
#

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

austere ivy
lilac willow
#

no

austere ivy
#

everytime i reset it looks like this?

lilac willow
#

ur misunderstanding

flat flower
#

I think the main

lilac willow
#

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

austere ivy
#

so why did mine not work?

lilac willow
#

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

austere ivy
#

ooh ok so what should it look like?

#

im trying to understand it

lilac willow
#

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

flat flower
#

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

lilac willow
#

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)

flat flower
#

Nah that a tough question

lilac willow
#

its not. its just not well asked

austere ivy
#

yep still not getting it?

lilac willow
#

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

austere ivy
lilac willow
#

thats not the javadoc

#

this is the official documentation of the JFrame class

#

if u scroll down u can find the add methods

#

which leads u here

#

so. what kind of class/type does this method expect?

austere ivy
#

add(Component comp)

lilac willow
#

yes. so which class/type does the add method expect?

austere ivy
#

Appends a specified component to a container

lilac willow
#

thats not what im asking

#

which class does MyDrawing need to extend from in order for someJFrame.add(new MyDrawing()) to work?

austere ivy
#

public Component add(Component comp)

lilac willow
#

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?

austere ivy
#

JFrame?

lilac willow
#

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

austere ivy
#

add method?

lilac willow
#

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

austere ivy
#

i just am not sure why my answer is incorrect thats all ? why is my answer incorrect?

lilac willow
#

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?

austere ivy
#

text right?

lilac willow
#

and whats its type?

austere ivy
#

public

lilac willow
#

which class is text from

austere ivy
#

Java AWT

lilac willow
#

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);
}
austere ivy
#

java?

lilac willow
#

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

austere ivy
#

yes

lilac willow
#

like, u need to learn about basics of programming, if, loops, methods, classes, OOP, ... before even attempting to do any of that stuff

echo prism
#

Is dog a String?

lilac willow
#

its a bit unfortuante that u dont stick with us so we can go through this quicker. im sadly out of time for now