Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Friday, May 24, 2013

How to Display a JavaScript-like Alert in Java

Just put the following in your Java code:

javax.swing.JOptionPane.showMessageDialog(null, "Your message here");

Note:
Similar to JavaScript, your code will pause executing until you close the message dialog. So be careful when deploying your code for the client.

Wednesday, June 6, 2012

How to Access Image Dimensions from MultipartFile in Java

Here's how to access image dimensions from MultipartFile:
java.awt.image.BufferedImage image = javax.imageio.ImageIO.read(new BufferedInputStream(multipartFile.getInputStream()));
System.out.println("Image height: " + image.getHeight());
System.out.println("Image width: " + image.getWidth());