Skip to content

Instantly share code, notes, and snippets.

@skrb
Last active September 26, 2019 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skrb/63d54dbd896afdf20baebd9e0bbba905 to your computer and use it in GitHub Desktop.
Save skrb/63d54dbd896afdf20baebd9e0bbba905 to your computer and use it in GitHub Desktop.
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.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