#I can't access an automatically generated variable in my java file

1 messages · Page 1 of 1 (latest)

reef terrace
#

Whenever I try to access my currency or open buttons and comboboxes, it says that they're an unknown class.
I know a class goes after public/private/protected/-, but I already defined thnat. By "I", I mean the program.

boreal merlinBOT
#

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

#

Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
Whenever I try to access my currency or open buttons and comboboxes, it says that they're an unknown class. I know a class goes after public/private/protected/-, but I already defined thnat. By "I", I mean the program.

the keyword "new" followed by the constructor, but the variables I'm trying to access are automatically generated. Is there a way to access these variables without explicitly declaring them in my Java file?

One possible solution could be to check if the variables are declared as private or protected within the class. If they are, you will need to use getter methods to access these variables outside of the class.

Another option could be to ensure that your IDE is properly importing the necessary packages for these automatically generated classes. You can do this by using the shortcut keys for importing packages in your IDE (such as Ctrl+Shift+O in Eclipse).

If you are still unable to access these automatically generated variables, it may be helpful to consult the documentation or resources provided by the tool or library generating these classes. They may have specific guidelines or instructions on how to work with their automatically generated code.

Overall, it's important to understand how these automatically generated variables are structured and how they can be accessed in your Java file. By following these tips and troubleshooting steps, you should be able to successfully access and utilize these variables in your code.

reef terrace
#

I'm using IntelliJ IDEA like a normal person

#

I still have no clue what to do

upper mesa
#

you need to give us more to work with

#

code snippets, screenshots, error messages...

reef terrace
#

apparently I can't access any variable defined outside a method

#

that's exactly my problem

upper mesa
#

again, too vague

#

what is happening here is that you don't understand something

#

so your explanations of what is going wrong also don't make sense

#

its fine

#

but i need more specific info

reef terrace
#

I recorded a video of y java file and the stuff it marks as errors, warnings and typos, but I can't find it

upper mesa
#

just send the code

#

CODE HERE

#

if it says its too big thats fine, click the "upload as file" button

reef terrace
#

alright

boreal merlinBOT
reef terrace
#

Ian't that what Discord does with .txt files usually?

upper mesa
#

okay so problem #1

#

for a field, you either initialize it in the constructor or in one line

#

if you need to do other logic, like add a bunch of items, you do this

#

so assign it in one line

#

do all the extra logic in this block

#

second issue, which is why it is all yellow, is that you are using JComboBox "raw"

#

JComboBoxes can store different things

#

Strings, ints, apples, whatever

#

this one is strings

#

so you write JComboBox<String>

#

next issue

#

i don't see convertHRK or convertMinecoins defined anywhere

#

i can't fix that for you, they just aren't there

#

next

#

so this is interesting

#

it is thinking that the currency on the right is the same as the currency on the left

#

you mean the JComboBox currency field

#

so to disambiguate - make not ambiguous - you can use this.

#

the yellow is because you don't need .toString() on something that is already a String

#

but i'll ignore that

#

this is more fundamental

#

a HashMap maps Type -> Type

#

and also you don't actually make the hashmap

#

currency isn't a type, thats a field

#

at which point i have to stop and ask

#

...how did you write this code?

#

if it was with the hinderance of an AI, stop

#

please

boreal merlinBOT
#

@reef terrace

Your question has been closed due to inactivity.

If it was not resolved yet, feel free to just post a message below
to reopen it, or create a new thread.

Note that usually the reason for nobody calling back is that your
question may have been not well asked and hence no one felt confident
enough answering.

When you reopen the thread, try to use your time to improve the quality
of the question by elaborating, providing details, context, all relevant code
snippets, any errors you are getting, concrete examples and perhaps also some
screenshots. Share your attempt, explain the expected results and compare
them to the current results.

Also try to make the information easily accessible by sharing code
or assignment descriptions directly on Discord, not behind a link or
PDF-file; provide some guidance for long code snippets and ensure
the code is well formatted and has syntax highlighting. Kindly read through
https://stackoverflow.com/help/how-to-ask for more.

With enough info, someone knows the answer for sure 👍

reef terrace