栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

【无标题】

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【无标题】

import java.awt.*;
import javax.swing.*;
class ComponentInWindow extends Jframe{
    JLabel label1,label2,label3,label4,label5,label6;

    public ComponentInWindow(){
        init();
        setVisible(true);
        setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);
    }

    void init(){
        setLayout(new FlowLayout());
        label1=new JLabel("black");
        label2=new JLabel("blue");
        label3=new JLabel("cyan");
        label4=new JLabel("green");
        label5=new JLabel("magenta");
        label6=new JLabel("orange");

        label1.setFont(new Font("Times Roman",Font.BOLD,20));
        label1.setForeground(Color.black);
        label1.setBackground(Color.white);
        label2.setFont(new Font("Times Roman",Font.BOLD,20));
        label2.setForeground(Color.blue);
        label2.setBackground(Color.white);
        label3.setFont(new Font("Times Roman",Font.BOLD,20));
        label3.setForeground(Color.cyan);
        label3.setBackground(Color.white);
        label4.setFont(new Font("Times Roman",Font.BOLD,20));
        label4.setForeground(Color.green);
        label4.setBackground(Color.white);
        label5.setFont(new Font("Times Roman",Font.BOLD,20));
        label5.setForeground(Color.magenta);
        label5.setBackground(Color.white);
        label6.setFont(new Font("Times Roman",Font.BOLD,20));
        label6.setForeground(Color.orange);
        label6.setBackground(Color.white);



        add(label1);
        add(label2);
        add(label3);
        add(label4);
        add(label5);
        add(label6);

    }
}
public class Main{
    public static void main(String argas[]){
        ComponentInWindow win = new ComponentInWindow();
        win.setBounds(50,50,300,200);
        win.setTitle("NAME");
    }
}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/591499.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号