#The import javax.swing.JOptionPane cannot be resolved

28 messages · Page 1 of 1 (latest)

foggy swallow
#

For some reason, it can't resolve JOptionPane. Running Eclipse 2022-09. Anyone got any idea what might be going wrong here?

signal agateBOT
#

This post has been reserved for your question.

Hey @foggy swallow! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed 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.

foggy swallow
#
int response = JOptionPane.showConfirmDialog(null,responseMsg, "Confirmation de reservation", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE);
``` Here's where I'm calling it
#
import javax.swing.AbstractListModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
#

Here's all my imports, everything is working perfectly fine, except for JOptionPane

restive cairn
#

Huh, that's very strange

#

Doesnt work for me either

#

In java 8, works perfectly, upgrade to 17: breaks

foggy swallow
#

Yeah, same thing im facing

#

Really weird

#

But i need it in java 17 💀

#

Apparently, JOptionPane is deprecated starting from java 17

#

Starting from Java 17, the JOptionPane class has been marked as deprecated, which means that it is no longer recommended for use in new code. Instead, you should use alternative classes from the javax.swing package or other libraries.

restive cairn
#

@foggy swallow in your module-info.java, add requires java.desktop;

#

that fixed it for me

foggy swallow
#
public void handleValidateEvent() {
        //Display confirmation window using JOptionPane
}
``` I love university
#

It's already in there

#
module tpcommunpartieihmdonnee {
    requires java.desktop;
    requires com.github.lgooddatepicker;
}
restive cairn
#

you saved the file?

foggy swallow
#

It's been in there since the start

restive cairn
#

oh

#

You can try adding the Java 8 library into your project

#

that also might work

foggy swallow
#

I'll see if that helps

#

Thanks!

signal agateBOT
# foggy swallow Thanks!

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.

restive cairn
#

make sure to close the post if you're done.