zoukankan      html  css  js  c++  java
  • java项目开发第五天——奋力完成数据库

    又一次成功地避开了UI界面,看来以后在这个部分得残了,无奈,心塞,不知为何。今天人品不好,大清早在群里签到居然和机器人聊起来了,顿时感觉智商被碾压,还下载了一个QQ空间背景复制器,看了看果真是实现了,顿时感觉平时最信任的东西顿时就倒塌了,还是以后好好的研究研究,不然着实是太……心塞了。

    http://blog.sina.com.cn/s/blog_6ad32c040100m5ei.html

    这个部分是详细的讲解了对时间部分的处理。

    晚上得好好的看看事件相应的部分了,这东西确实是挺……好学但是却不看就狠狠的掉队的东西了。看着别人设计好的漂亮的界面,我还是好好的从基础开始写起吧。

    先贴代码:

    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    
    public class InnerClassTest extends JFrame
    {
        JButton b;
        // 定义构造函数
        public InnerClassTest()
        {
            super("Testing Inner Class");
            Container c = this.getContentPane();
            c.setLayout(new FlowLayout());
            b = new JButton("退出聊天室");        
            MyButtonListener bListener = new MyButtonListener();
            b.addActionListener(bListener);
            c.add(b);
            this.setLocationRelativeTo(null);
            this.setSize(270,100);
            this.setVisible(true);
        }
        // 定义内部类
        class MyButtonListener implements ActionListener
        {
            // 定义事件处理方法
            public void actionPerformed(ActionEvent e)
            {
                System.exit(0);
            }
        }
    }
    View Code

     定义了内部类,这也就充分的体现了注册的作用。

    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class JTextTest extends JFrame
    {
        private JPanel p;
        private JTextArea ta;
        private JTextField tf;
        private JButton bt;
        public JTextTest()
        {
            super("我的聊天室");
            Container c = this.getContentPane();    //获得内容面板        
            p = new JPanel();
            p.setLayout(new BoxLayout(p,BoxLayout.Y_AXIS));
            ta = new JTextArea(10,20);    //创建一个显示10行20列的文本区        
            ta.setLineWrap(true);         //设置文本区ta可以自动换行
            ta.setWrapStyleWord(true);    //设置文本区ta的自动换行的模式是以单词为单位,而不是以单个字符为单位
            ta.setEditable(false);
            tf = new JTextField(20);
            tf.setFocusable(true);
            bt = new JButton("发送消息");
            
            bt.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                    ta.append(tf.getText().trim());
                    tf.setText("");
                }
            });        
            p.add(ta);
            p.add(tf);
            p.add(bt);        
            c.add(p);        
            this.setSize(400,250);
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.setLocationRelativeTo(null);
            this.setVisible(true);
        }
    }
    我要坚持一年,一年后的成功才是我想要的。
  • 相关阅读:
    PHP trim() 函数
    php 计算2个日期的相差天数
    php date('Y-n-j')的和date('Y-m-d')的区别
    转移服务器
    Invalid argument supplied for foreach()解决办法
    wordpress 后台忘记密码怎么办
    qrcode js插件生成微信二维码
    thinkphp5 注释
    tp5 新增完数据,获取id
    resstFul服务文件上传下载
  • 原文地址:https://www.cnblogs.com/tianxia2s/p/3970805.html
Copyright © 2011-2022 走看看