zoukankan      html  css  js  c++  java
  • JAVA GUI学习

     1 /**
     2  * JDilog学习笔记
     3  * @author Wfei
     4  *
     5  */
     6 public class JDialogKnow extends JFrame
     7 {
     8     JDialog jDialog;
     9     JButton jButton;
    10     public JDialogKnow()
    11     {
    12         init();
    13         
    14         this.setTitle("主窗体");
    15         this.setLayout(null);
    16         this.setSize(500, 500);
    17         this.setLocationRelativeTo(null);
    18         this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    19         
    20         this.add(jButton);
    21     }
    22     public void init()
    23     {
    24         /*************************JDialog学习******************************/
    25         //第一个参数:即该Dialog属于哪个窗体、对话框、窗口
    26         //第二个参数:即该Dialog是属于模式对话框,还是属于非模式对话框
    27         jDialog = new JDialog(this, true);
    28         jDialog.setLayout(null);
    29         jDialog.setTitle("我是Dialog");
    30         jDialog.setSize(300, 200);
    31         jDialog.setLocationRelativeTo(null);
    32         JLabel jLabel = new JLabel("我是Dialog中的Lable");jLabel.setBounds(10, 10, 200, 30);
    33         //jDialog也是类似于容器的,因此可以在其中添加组件
    34         jDialog.add(jLabel);
    35         //这里默认是false,只有在某事件发生时,才会触发该Dialog的呈现,本例通过Button来触发事件
    36 //        jDialog.setVisible(false);
    37         
    38         jButton = new JButton("点击我 - 打开Dialog");
    39         jButton.setBounds(50, 50, 200, 30);
    40         jButton.addActionListener(new ActionListener()
    41         {
    42             @Override
    43             public void actionPerformed(ActionEvent e)
    44             {
    45                 jDialog.setVisible(true);
    46                 //或jDialog.show();
    47             }
    48         });
    49     }
    50     public static void main(String[] args)
    51     {
    52         JDialogKnow jDialogKnow = new JDialogKnow();
    53         jDialogKnow.setVisible(true);
    54     }
    55 }
  • 相关阅读:
    java api 中的设计模式之组合(composite)
    Java api 中设计模式之适配器模式(Adapter)
    win 7 C盘清理
    centos 与 redhat 以及 mysql 与 Oracle
    tsung生成报表时报错
    对MySQL的死连接Sleep的进程的来源研究[转]
    商派ecstore后台配置微信支付应该注意的问题
    商派crm的内存计算组件配置mysql5.6的问题
    php-curl无法编译
    ecstore目录系统预占字符
  • 原文地址:https://www.cnblogs.com/Wfei/p/3332619.html
Copyright © 2011-2022 走看看