JAVA GUI界面包

  1. import javax.swing.*;
  2. import java.awt.*;
  3. public class GuiJava extends JFrame {
  4.     
  5.     Container container;
  6.     //container size
  7.     public GuiJava (int width, int height, String name) {
  8.         super(name);
  9.         setBasic(width, height);
  10.     }
  11.     
  12.     public GuiJava (String name) {
  13.         super(name);
  14.         //default
  15.         setBasic(200200);
  16.     }
  17.     
  18.     public void setBasic(int width, int height)
  19.     {
  20.         container = this.getContentPane();
  21.         container.setLayout(null);
  22.         this.setResizable(false);
  23.         this.setVisible(true);
  24.         this.setSize(width, height);
  25.         this.setLocation(500300);
  26.         this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
  27.     }
  28.     
  29.     //component location
  30.     public void addComponentSet(Component compo0, int x, int y)
  31.     {
  32.         compo0.setLocation(x, y);
  33.         //default
  34.         compo0.setSize(5050);
  35.         container.add(compo0);
  36.     }
  37.     
  38.     //component location and size
  39.     public void addComponentSet(Component compo0, int x, int y, int width, int height)
  40.     {
  41.         compo0.setSize(width, height);
  42.         compo0.setLocation(x, y);
  43.         container.add(compo0);
  44.     }
  45.     
  46. }
以下给出一个实例
看看是如何使用
         
  1. import javax.swing.*;
  2. public class Sample {
  3.     public static void main (String[] args) {   
  4.         GuiJava com = new GuiJava("java");
  5.         JLabel label = new JLabel("hello");
  6.         com.addComponentSet(label, 1010);
  7.     }
  8. }    
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值