zoukankan      html  css  js  c++  java
  • 学习java窗口基本操作时无聊写的

    学习java窗口基本操作时无聊写的

    就当记录

    代码如下:

    package day08;

    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.FlowLayout;
    import java.awt.Font;
    import java.awt.GridLayout;

    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.border.LineBorder;
    import javax.swing.border.TitledBorder;

    public class Testketianglianxin extends JFrame {
    public Testketianglianxin() {

    Font font1 = new Font("Serif", Font.BOLD + Font.ITALIC, 20);
    Font jbutton1 = new Font("Dialog", Font.PLAIN + Font.BOLD, 20);
    Font count1 = new Font("楷体", Font.BOLD + Font.PLAIN, 20);

    TitledBorder help = new TitledBorder("hello world");
    TitledBorder titledBorder = new TitledBorder("三个按钮");

    LineBorder lb1 = new LineBorder(Color.RED,4);
    LineBorder lb2 = new LineBorder(Color.ORANGE,4);




    JPanel p1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    JButton btn1 = new JButton("Left");
    btn1.setForeground(new Color(FRAMEBITS));
    btn1.setToolTipText("00000000");
    btn1.setFont(font1);

    JButton jbutton = new JButton("center");
    jbutton.setForeground(new Color(120, 25, 30));
    jbutton.setFont(jbutton1);

    JButton jbutton2 = new JButton("Right");
    jbutton2.setFont(count1);

    p1.add(jbutton);
    p1.add(btn1);
    p1.add(jbutton2);
    JPanel p2 = new JPanel(new GridLayout(1,2));
    JLabel label1 = new JLabel("Red");
    JLabel label2 = new JLabel("Orange");
    p2.add(label1);
    p2.add(label2);

    label1.setBorder(lb1);
    label2.setBorder(lb2);

    // Font help1 = new Font("楷体", Font.BOLD + Font.PLAIN, 20);
    // 创建边框
    // 给p1设置边框
    p1.setBorder(titledBorder);
    p2.setBorder(help);
    setLayout(new GridLayout(2, 1, 5, 5));
    add(p1);
    add(p2);
    }

    public static void main(String[] args) {
    Testketianglianxin fr = new Testketianglianxin();
    fr.setSize(500, 300);
    fr.setLocationRelativeTo(null);
    fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    fr.setVisible(true);
    }
    }

    只相信苦尽甘来
  • 相关阅读:
    支付宝校园一卡通充值服务体验
    商品筛选导航菜单亮点欣赏
    手机QQ v4.2 有感
    因所缺,而所需——互联网应用的开发方向
    浅谈 css3 box盒子模型以及box-flex的使用
    浅谈stylus与sass的对比
    css3 transfrom使用以及其martix(矩阵)属性与其它属性的关系
    js命名空间
    公用的stringUtil工具
    js 实现angylar.js view层和model层双绑定(改变view刷新 model,改变model自动刷新view)
  • 原文地址:https://www.cnblogs.com/F001li/p/7055977.html
Copyright © 2011-2022 走看看