Popular Posts
javax.net.ssl.SSLHandshakeException: Connection closed by peer in Android 5.0 Lollipop Recently, there is a error occurs when access website via ssl connection like below although it worked fine several days ago. // Enable SSL... Tired of Hibernate? Try JDBI in your code JDBI Quick sample ICategoryDAO.java : create a data access interface (implement is not required) package com.prhythm.erotic.task.data.... Enable SSL connection for Jsoup import org.jsoup.Connection; import org.jsoup.Jsoup; import javax.net.ssl.*; import java.io.IOException; import java.security.KeyManagement...
Stats
Resize image (awt)
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class ResizeImageFrame extends JFrame {

    public ResizeImageFrame() throws IOException {
        setTitle("Resize image");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLayout(new FlowLayout());

        JLabel img1 = new JLabel();
        img1.setIcon(new ImageIcon(getClass().getResource("/arrow_right.png")));
        add(img1);

        BufferedImage icon2 = ImageIO.read(getClass().getResource("/arrow_right.png"));
        // resize image
        AffineTransform transform = AffineTransform.getScaleInstance(30.0 / icon2.getWidth(), 30.0 / icon2.getHeight());
        AffineTransformOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
        icon2 = op.filter(icon2, null);
        JLabel img2 = new JLabel();
        img2.setIcon(new ImageIcon(icon2));
        add(img2);

        pack();
        Dimension sc = Toolkit.getDefaultToolkit().getScreenSize();
        setLocation(new Point((sc.width - getWidth()) / 2, (sc.height - getHeight()) / 2));
        setVisible(true);
    }

    /**
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub

        new ResizeImageFrame();
    }

}