Created
January 29, 2011 14:50
-
-
Save blackraccoon000/801886 to your computer and use it in GitHub Desktop.
Frame7_2
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 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); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment