知行合一

享受过程 漠视结果

导航

JavaDemo

import java.awt.Button;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class HelloForm extends Frame {
    public HelloForm() {
        setTitle("Java Demo");
        setSize(600, 400);
        setResizable(false);
        setLocationRelativeTo(getOwner());
        setVisible(true);

        this.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

        Panel panel1 = new Panel();
        panel1.setBackground(Color.blue);
        panel1.setLocation(0, 0);
        
        Panel panel2 = new Panel();
        panel2.setBackground(Color.red);
        panel2.setLocation(0, 30);
        
        add(panel1);
        add(panel2);
    }

    private void p1init() {
        Panel p1, p2, p3;
        Button b1, b2, b3;
        Button n1, n2;
        Button s1, s2;
        p1 = new Panel();

        p1.setBackground(Color.blue);
        p1.setLocation(0, 30);
        p1.setSize(200, 50);

        add(p1);
    }
}
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

public class Base64 {

    public static byte[] decryptBASE64(String key) throws Exception {
        return (new BASE64Decoder()).decodeBuffer(key);
    }

    public static String encryptBASE64(byte[] key) throws Exception {
        return (new BASE64Encoder()).encodeBuffer(key);
    }

    public static void main(String[] args) throws Exception {
        String data = Base64.encryptBASE64("hello".getBytes());
        System.out.println( data);

        byte[] byteArray = Base64.decryptBASE64(data);
        System.out.println(new String(byteArray));
    }
}

 

package DAL;

import javax.swing.*;
import java.awt.*;

public class wang extends JFrame {
    private static final long serialVersionUID = 1L;
    private Container contentPane;
    private JLabel lbl;

    public wang() {
        contentPane = getContentPane();
        lbl = new JLabel("Hello World :->", 0);
        contentPane.add(lbl);
        setSize(640, 480);
        // setLocation(new Point(200, 300));
        setLocationRelativeTo(this);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new wang().setVisible(true);
    }
}

 

posted on 2013-01-30 11:08  项羽  阅读(399)  评论(0编辑  收藏  举报