⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractcomponents.java

📁 Swing入门必看 Swing Demo
💻 JAVA
字号:
/*
 * @(#)AbstractComponents.java 2007-4-27
 * Copyright 2007 AIC. All rights reserved. 
 */
package components;

import java.awt.*;

import javax.swing.*;

/**
 * Common JFrame contained vertical box, and set default properties
 * 
 * Note: 
 * 		protected abstract void initComponents(Box box); 
 * 
 * @author Henry Zhu
 */
public abstract class AbstractComponents extends JFrame {

	private static final long serialVersionUID = 1L;

	protected abstract void initComponents(Box box); 
	
	/**
	 * set up common GUI
	 */
	public AbstractComponents(String title) {
		// invoke super constructor with the specified title
		super(title);

		// create Box containers with BoxLayout
		Box box = Box.createVerticalBox();
		box.add(Box.createVerticalStrut(10));
		
		// init compontents and add them into box
		initComponents(box);
		
		// get content pane and set its layout
		Container container = getContentPane();
		container.setLayout(new FlowLayout());
		container.add(box);

		// set size for the frame and show the frame
		setSize(300, 400);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setVisible(true);
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -