组件使用之通缉令_day5_0314

package day5_0314;

import java.awt.Color;
import java.awt.Font;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class MyJFrameTest extends JFrame{
    
    public MyJFrameTest(){
        this.setLayout(null);
        JLabel j = new JLabel("通缉令");
        j.setForeground(Color.red);
        j.setFont(new Font("黑体",Font.ITALIC,30));
        j.setBounds(100,0,100,50);
        this.add(j);
        
        JTextArea jta = new JTextArea("ALIVE OR DEAD");
        jta.setForeground(Color.red);
        jta.setFont(new Font("黑体",Font.ITALIC,30));
        jta.setLineWrap(true);
        jta.setBounds(50,350,200,50);
        this.add(jta);
        
        JLabel jl = new JLabel("奖金");
        jl.setForeground(Color.red);
        jl.setFont(new Font("黑体",Font.ITALIC,30));
        jl.setBounds(50,400,100,50);
        this.add(jl);
        
        JComboBox box = new JComboBox();
        box.addItem("100000000$");
        box.addItem("200000000$");
        box.addItem("300000000$");
        box.setBounds(120,420,100,30);
        this.add(box);
        
        JButton button = new JButton("领取");
        button.setBounds(120,450,60,30);
        this.add(button);
                
        Image img = new ImageIcon("img/海贼王.jpg").getImage();
        img = img.getScaledInstance(200,300, 1);
        JLabel j1Imag = new JLabel(new ImageIcon(img));
        j1Imag.setBounds(50,50,200,300);
        this.add(j1Imag);
                
        /**设置窗体大小*/
        this.setSize(300,600);
        /**设置窗体的可见程度*/
        this.setVisible(true);
        /**设置标题*/
        this.setTitle("wanted");
        /**窗体关闭,程序结束*/
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        /**设置窗体居中显示*/
        this.setLocationRelativeTo(null);
        /**设置窗体不能改变大小*/
        this.setResizable(true);
    }
    
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        MyJFrameTest mjt = new MyJFrameTest();
    }

}

 

posted @ 2017-03-14 23:25  沉迷学习,日渐消瘦  阅读(94)  评论(0)    收藏  举报