Rotate JLabel or ImageIcon on Java Swing

Instead of rotating the component itself, consider rotating the content of a component. This example draws a rotated image in a JPanel. Addendum: In the example RotatableImage.getImage() creates a BufferedImage directly in memory, but you can use ImageIO.read() to obtain an image from elsewhere. BufferedImage#createGraphics() is supported if you want to modify the image, but … Read more

How to make Circle image Label in Java?

I think you should change your tack, instead of trying to modify the output of a component, instead, modify the input… So all this does, is apply a circular (alpha based) mask to another image BufferedImage master = ImageIO.read(new File(“/Volumes/Disk02/Dropbox/MegaTokyo/thumnails/megatokyo_omnibus_1_3_cover_by_fredrin-d4oupef.jpg”)); int diameter = Math.min(master.getWidth(), master.getHeight()); BufferedImage mask = new BufferedImage(master.getWidth(), master.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = … Read more

Java: how to add image to Jlabel?

You have to supply to the JLabel an Icon implementation (i.e ImageIcon). You can do it trough the setIcon method, as in your question, or through the JLabel constructor: Image image=GenerateImage.toImage(true); //this generates an image file ImageIcon icon = new ImageIcon(image); JLabel thumb = new JLabel(); thumb.setIcon(icon); I recommend you to read the Javadoc for … Read more

How to remove gap in java swing label of large size

JDigit may give you some ideas: It override’s paintComponent() to down-sample a high-resolution BufferedImage and control the geometry. It uses setBorderPainted(false) to set the borderPainted property. It uses a FocusHandler for custom highlighting. Addendum: As noted here, the underlying problem is the font’s leading, defined in FontMetrics as being included in the font’s height. As … Read more

Resize a picture to fit a JLabel

Outline Here are the steps to follow. Read the picture as a BufferedImage. Resize the BufferedImage to another BufferedImage that’s the size of the JLabel. Create an ImageIcon from the resized BufferedImage. You do not have to set the preferred size of the JLabel. Once you’ve scaled the image to the size you want, the … Read more

Why is my JLabel not showing up

The problem you’re having is you’re blocking the Event Dispatching Thread, prevent the UI from been updated or any new events from been processed… It starts here… for(int i = 0; i < 15; i++) { //… //Check to see if user has enetered anything // And is compounded here while(!answered) { Thread.sleep(duration); //… } … Read more