zoukankan      html  css  js  c++  java
  • 吴裕雄--天生自然JAVA图形界面编程学习笔记:按钮组件JButton

    import javax.swing.JFrame ;
    import javax.swing.JButton ;
    import java.awt.Font ;
    public class JButtonDemo01{
        public static void main(String args[]){
            JFrame frame = new JFrame("Welcome To MLDN") ;    // 实例化窗体对象
            JButton but = new JButton("按我") ;     
            Font fnt = new Font("Serief",Font.BOLD,28);
            but.setFont(fnt) ;
            frame.add(but) ;
            frame.setSize(200,70) ;
            frame.setLocation(300,200) ;
            frame.setVisible(true) ;
        }
    };
    import javax.swing.JFrame ;
    import javax.swing.JButton ;
    import javax.swing.Icon ;
    import javax.swing.ImageIcon ;
    import java.io.File ;
    import java.awt.Font ;
    public class JButtonDemo02{
        public static void main(String args[]){
            JFrame frame = new JFrame("Welcome To MLDN") ;    // 实例化窗体对象
            String picPath = "d:" + File.separator + "mldn.gif" ;
            Icon icon = new ImageIcon(picPath) ;
            JButton but = new JButton(icon) ;     
            frame.add(but) ;
            frame.setSize(300,160) ;
            frame.setLocation(300,200) ;
            frame.setVisible(true) ;
        }
    };
  • 相关阅读:
    Vue.js 学习报告
    Javascript 巩固:阮一峰javascript教程 (2017-1-17)
    2017-1-17
    my-Life项目开发流程-02
    《Javascript 权威指南 第六版》
    2017-1-11
    2017-1-10
    2017-1-9
    前端知识解惑: 响应式 兼容性 不错的知识链接
    2017-1-3
  • 原文地址:https://www.cnblogs.com/tszr/p/12398783.html
Copyright © 2011-2022 走看看