JavaSwing+derby电子相册

本文介绍如何使用Java创建并展示电子相册界面,包括布局管理、组件初始化及窗口定位,实现简单而直观的相册浏览体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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;
}


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值