Last active
September 26, 2019 14:48
-
-
Save skrb/63d54dbd896afdf20baebd9e0bbba905 to your computer and use it in GitHub Desktop.
Swing Image View Demo
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 net.javainthebox.imageview; | |
import java.awt.BorderLayout; | |
import java.awt.Dimension; | |
import javax.swing.ImageIcon; | |
import javax.swing.JFrame; | |
import javax.swing.JLabel; | |
import javax.swing.JPanel; | |
import javax.swing.SwingUtilities; | |
public class Main { | |
public Main() { | |
JPanel root = new JPanel(); | |
root.setLayout(new BorderLayout()); | |
JLabel label = new JLabel(new ImageIcon("イメージファイル")); | |
root.add(label, BorderLayout.CENTER); | |
JFrame frame = new JFrame(); | |
frame.add(root); | |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
frame.setSize(new Dimension(630, 450)); | |
frame.setVisible(true); | |
} | |
public static void main(String[] args) { | |
SwingUtilities.invokeLater(() -> new Main()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment