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

📄 swingclass.java

📁 jsp网络编程从基础到实践源代码
💻 JAVA
字号:
/*
 * Created on Mar 2, 2004
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package org.cookbook.ch08;

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

/**
 * @author Steven Holzner
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class SwingClass extends JFrame {

	Panel p;

	public SwingClass() 
	{
		super("Swing Example");

		Container contentPane = getContentPane();
		p = new Panel();
		contentPane.add(p);
	}

	public static void main(String args[]) 
	{
		final JFrame f = new SwingClass();

		f.setBounds(100, 100, 280, 250);
		f.setVisible(true);
		f.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		
		f.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});
	}
}

class Panel extends JPanel 
{
	Panel()
	{
		setBackground(Color.white);
	}
	
	public void paintComponent (Graphics g)
	{
		super.paintComponent(g);
		g.drawString("Greetings from Swing", 70, 100);
	}
}

⌨️ 快捷键说明

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