天天看點

JavaSwing+derby電子相冊

JavaSwing+derby電子相冊

此隻為主類,完整可執行程式及源代碼:點選打開連結

import java.awt.EventQueue;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.GroupLayout;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import tool.ScreenSize;


public class AlbumFrame extends JFrame{
	public AlbumFrame(){
		initComponents();
		ScreenSize.centered(this);
	}

	private void initComponents() {
		albumPanel1 = new AlbumPanel();
		this.setDefaultLookAndFeelDecorated(true);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setTitle("電子相冊");
		GroupLayout layout = new GroupLayout(getContentPane());
		getContentPane().setLayout(layout);
		
		//設定沿水準軸确定元件位置和大小的 Group。 Parallel:n. 平行線;對比
		layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
				.addComponent(albumPanel1, GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE));
		//設定沿垂直軸确定元件位置和大小的 Group。
		layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
				.addComponent(albumPanel1, GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE));
		this.pack();
	}

	public static void main(String[] args) throws IllegalAccessException {
		/*
		try{
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		}catch(ClassNotFoundException e){
			//Level 類定義了一組可用來控制日志輸出的标準日志級别。severe:最進階别
			//log()記錄帶有相關的可抛出資訊的消息。 
			Logger.getLogger(AlbumFrame.class.getName()).log(Level.SEVERE, null, e);
		}catch(InstantiationException e){
			Logger.getLogger(AlbumFrame.class.getName()).log(Level.SEVERE, null, e);
		}catch(UnsupportedLookAndFeelException e){
			Logger.getLogger(AlbumFrame.class.getName()).log(Level.SEVERE, null, e);
		}*/
		EventQueue.invokeLater(new Runnable(){
			public void run(){
				new AlbumFrame().setVisible(true);
			}
		});
	}
	
	private AlbumPanel albumPanel1;
}
           

繼續閱讀