Skip to content

Instantly share code, notes, and snippets.

Last active Sep 26, 2019
What would you like to do?
Swing Image View Demo
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.setSize(new Dimension(630, 450));
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