Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package frame;
- import javax.swing.*;
- import javax.swing.border.Border;
- import java.awt.*;
- /**
- * Created by IntelliJ IDEA.
- * User: white
- * Date: 11/01/29
- * Time: 8:07
- * To change this template use File | Settings | File Templates.
- */
- public class Frame7 extends JFrame {
- public static void main(String args[]){
- Frame7 frame = new Frame7("icon");
- frame.setVisible(true);
- }
- Frame7(String title){
- setTitle(title);
- setBounds(100,100,300,250);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- //iconの画像を相対パスで取得
- ImageIcon icon = new ImageIcon("./src/main/java/frame/d.png");
- //アイコンに画像を指定
- setIconImage(icon.getImage());
- //Panelにラベルを貼り付ける
- JPanel p1 = new JPanel();
- p1.add(new JLabel("title"));
- p1.add(new JLabel(icon));
- //パネルを配置
- Container contentPane = getContentPane();
- contentPane.add(p1, BorderLayout.NORTH);
- }
- }
Add Comment
Please, Sign In to add comment