javax.swing.JOptionPane dont want to import

I want to make the programm that I screened and I don't understand why it don't want to import JOptionPane... Could someone help me pls ?
No description
18 Replies
JavaBot
JavaBot4w ago
This post has been reserved for your question.
Hey @"Pom'! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
ayylmao123xdd
ayylmao123xdd4w ago
did you try importing like this
import javax.swing.*;
import javax.swing.*;
"Pom'
"Pom'OP4w ago
i'll try it
dan1st
dan1st4w ago
Do you have a module-info.java? If yes, add requires java.desktop; in it
"Pom'
"Pom'OP4w ago
idk what that is
dan1st
dan1st4w ago
check your src folder I think there's a module-info.java file there So your application is a module, libraries consist of modules and the JDK contains multiple modules. The module-info.java file specifies which modules your module (your application) is allowed to access
dan1st
dan1st4w ago
When creating a Java project, Eclipse has an option for that actually
No description
dan1st
dan1st4w ago
If you hover the error, it would say something like
package javax.swing is not accessible
and also include a quick fix saying something like
add "requires java.desktop" to module-info.java
Selecting that option does the same - it edits the module-info.java file and configures it in a way that accessing Desktop/Swing packages is allowed
ayylmao123xdd
ayylmao123xdd4w ago
yea do what daniel said if my thing didnt work
"Pom'
"Pom'OP4w ago
it don't work x) how do I add it ? it seems to be the solution
dan1st
dan1st4w ago
Can you show your module-info.java? it probably looks similar to
module somemodule {
// probably no content here
// but it can contain things like the following
requires java.sql;
}
module somemodule {
// probably no content here
// but it can contain things like the following
requires java.sql;
}
"Pom'
"Pom'OP4w ago
where do I find this ? Oh I found it
"Pom'
"Pom'OP4w ago
No description
dan1st
dan1st4w ago
so within the {}, add a requires java.desktop;
"Pom'
"Pom'OP4w ago
it's imported thanks
JavaBot
JavaBot4w ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
JavaBot
JavaBot4w ago
Post Closed
This post has been closed by <@204032198360170496>.

Did you find this page helpful?