zoukankan      html  css  js  c++  java
  • Java——按钮组件:JButton

    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.Point;
    
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    
    //=================================================
    // File Name       :	JFrame_demo
    //------------------------------------------------------------------------------
    // Author          :	Common
    
    
    
    //主类
    //Function        : 	JFrame_demo
    public class JFrame_demo {
    
    	public static void main(String[] args) {
    		// TODO 自动生成的方法存根
    		
    		JFrame f = new JFrame("Swing窗口");							//实例化窗体对象
    		String picPath = "/home/common/software/database/photo.jpg";
    		Icon icon = new ImageIcon(picPath);
    		
    		JButton but = new JButton(icon);
    		f.add(but);																				//向容器中加入组建
    		Dimension dim = new Dimension();								//实例化Dimension对象
    		
    		dim.setSize(230,80);			//设置大小
    		f.setSize(dim);						//设置组件大小
    		f.setBackground(Color.WHITE);
    		Point point = new Point(300,200);		//设置现实的坐标点
    		f.setLocation(point);
    		f.setVisible(true);
    		
    	}
    
    }
    
  • 相关阅读:
    GeoServer与Spring MVC
    GeoServer二次开发1 hello Geoserver
    servlet的生命周期
    springboot打包出错,没有主清单
    空间数据库管理
    Gone with the wind
    谎言中的民众
    还是有些怀念这里啊
    MSN Protcol 学习笔记
    祝我的老师教师节快乐!
  • 原文地址:https://www.cnblogs.com/tonglin0325/p/5308786.html
Copyright © 2011-2022 走看看