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

📄 guidemo2.java

📁 java程序设计语言源代码
💻 JAVA
字号:
//Example 2 of Chapter 5

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

public class GUIDemo2
{
	public static void main(String[] args)
	{
		JFrame f = new JFrame("FlowLayout布局管理器演示");
		
		JPanel contentpane = new JPanel();
		
		JButton bred = new  JButton("red");
		JButton bgreen = new  JButton("green");
		JButton bblue = new  JButton("blue");
		JButton bcyan = new  JButton("cyan");
		JButton bmagenta = new  JButton("magenta");
		JButton byellow = new  JButton("yellow");
		
		bred.setBackground(Color.red);
		bgreen.setBackground(Color.green);
		bblue.setBackground(Color.blue);
		bcyan.setBackground(Color.cyan);
		bmagenta.setBackground(Color.magenta);
		byellow.setBackground(Color.yellow);
		
		contentpane.setLayout(new FlowLayout(FlowLayout.LEFT));
		f.setContentPane(contentpane);
		
		contentpane.add(bred);
		contentpane.add(bgreen);
		contentpane.add(bblue);
		contentpane.add(bcyan);
		contentpane.add(bmagenta);
		contentpane.add(byellow);
		
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		f.setSize( 600 , 100 );
		f.setVisible(true);
	}
}

⌨️ 快捷键说明

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