Created
October 20, 2015 23:58
-
-
Save arwagner/32ce2e3ec5d9d23041d9 to your computer and use it in GitHub Desktop.
Something I'm not understanding about resizing labels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.andrewwagner.chess.study; | |
import java.awt.Image; | |
import java.io.File; | |
import java.io.IOException; | |
import javax.imageio.ImageIO; | |
import javax.swing.ImageIcon; | |
import javax.swing.JFrame; | |
import javax.swing.JLabel; | |
import javax.swing.JPanel; | |
public class Main { | |
public static void main(String[] args) throws IOException{ | |
JFrame frame = new JFrame(); | |
final JPanel panel = new JPanel(); | |
final JLabel label = new JLabel(); | |
panel.add(label); | |
frame.add(panel); | |
frame.pack(); | |
frame.setVisible(true); | |
Image image = ImageIO.read(new File("/Users/andrew/Downloads/Programming.jpg")); | |
label.setIcon(new ImageIcon(image)); | |
label.revalidate(); | |
panel.revalidate(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment