swing绘图体系

来源:互联网 发布:耐驰热分析软件 编辑:程序博客网 时间:2024/05/20 22:50

据说这个不是很有用,其实我也觉得不是很有用,因为这个做界面绝世太丑了,而且不是很方便使用,同时绘图也不是java的强项,但是,作为学习,还是有一定的必要的,总体来说难度不是很大,但是需要记忆的东西比较多。下面是简单的代码实例:

package com_1;import java.awt.*;import javax.swing.*;public class demon_2_6 extends JFrame{    JPanel jp1,jp2,jp3;    JButton jb1,jb2;    JLabel jlb1,jlb2;    JTextField jtf1,jpf1;    public static void main(String[] args) {        demon_2_6 demon_2_6=new demon_2_6();    }    public demon_2_6(){        jp1=new JPanel();        jp2=new JPanel();        jp3=new JPanel();        jlb1=new JLabel("用户名");        jlb2=new JLabel("密码");        jb1=new JButton("登录");        jb2=new JButton("取消");        jtf1=new JTextField(10);        jpf1=new JPasswordField(10);        this.setLayout(new GridLayout(3,1));        jp1.add(jlb1);        jp1.add(jtf1);        jp2.add(jlb2);        jp2.add(jpf1);        jp3.add(jb1);        jp3.add(jb2);        this.add(jp1);        this.add(jp2);        this.add(jp3);        this.setTitle("网格布局");        this.setSize(300,200);//      this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        this.setLocation(200,200);        this.setVisible(true);    }}
0 0
原创粉丝点击