I want to play around with some image manipulation code I'm writing, so I'd like to use the Scala console or something like BlueJ's Java CodePad to create a java.awt.Image and then just pop it up to look at.
Ideally, it'd just be a panel or something without a Frame that would appear and I could just click it to make it disappear. Is there a way to make something that lightweight, or do I really need some kind of frame and more scaffolding?
JOptionPane.showMessageDialog(parent, new JLabel(new ImageIcon(theImage)));
Of course, if you have an URL
for the image (or can form one from a File
path), it can also be displayed as a tool-tip using HTML.
See Show full Image when hover over thumbnail for source.
In Scala, use the Java Swing ImageIcon
val img = new ImageIcon("path/to/file.jpg")
with Scala Swing Dialog
Dialog.showMessage(message = img)
Or better, display the image instead of the alert icon:
Dialog.showMessage(message = null, icon = img)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With