COM6516-Week09

栏目: Java · 发布时间: 6年前

CornerString.java
/*
 * Developed by Neo on 19/11/18 11:54.
 * Last modified 19/11/18 11:54.
 * Copyright (c) 2018. All rights reserved.
 */

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

public class CornerString extends JFrame {
	public CornerString() {
		super("Corner String");

		//For better looks.
		try {
			UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
		} catch (Exception e) {
			e.printStackTrace();
		}

		this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		this.setSize(960, 480);
		this.setResizable(false);
		this.setLocationRelativeTo(null);

		this.setContentPane(new StringPanel());

		this.setVisible(true);
	}

	public static void main(String[] args) {
		new CornerString();
	}

	public class StringPanel extends JPanel {
		public StringPanel() {
			super(new BorderLayout());

			JLabel label1 = new JLabel("To be or not to be");
			JLabel label2 = new JLabel("To be or not to be");
			JLabel label3 = new JLabel("To be or not to be");
			JLabel label4 = new JLabel("To be or not to be");

			label1.setFont(new Font("Consolas", Font.PLAIN, 32));
			label1.setForeground(Color.BLUE);
			label2.setFont(new Font("Comic Sans MS", Font.PLAIN, 32));
			label2.setForeground(Color.GREEN);
			label3.setFont(new Font("Monospaced", Font.PLAIN, 32));
			label3.setForeground(Color.RED);
			label4.setFont(new Font("Courier", Font.PLAIN, 32));
			label4.setForeground(Color.YELLOW);

			JPanel northPanel = new JPanel();
			northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.X_AXIS));

			northPanel.add(label1);
			northPanel.add(Box.createHorizontalGlue());
			northPanel.add(label2);

			JPanel southPanel = new JPanel();
			southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.X_AXIS));

			southPanel.add(label3);
			southPanel.add(Box.createHorizontalGlue());
			southPanel.add(label4);

			add(northPanel, BorderLayout.NORTH);
			add(southPanel, BorderLayout.SOUTH);
		}
	}
}
GIFFrame.java
/*
 * Developed by Neo on 19/11/18 15:44.
 * Last modified 19/11/18 15:44.
 * Copyright (c) 2018. All rights reserved.
 */

import javax.swing.*;

public class GIFFrame extends JFrame {
	public GIFFrame() {
		super("GIF Frame");

		setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

		ImageIcon imageIcon = new ImageIcon("globe.gif", "globe");

		setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight());

		JLabel imageLabel = new JLabel(imageIcon);

		add(imageLabel);

		setLocationRelativeTo(null);

		setVisible(true);
	}

	public static void main(String[] args) {
		new GIFFrame();
	}
}

以上所述就是小编给大家介绍的《COM6516-Week09》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

八年级数学(华东师大版)-解题升级-解题快速反应一本通(新课标)

八年级数学(华东师大版)-解题升级-解题快速反应一本通(新课标)

孙丽敏等编 / 吉林教育出版社 / 2004-6 / 10.0

本书将与知识点、重点、难点和考点有关的典型题做全析全解,是具有解题题典性质的助学读物。但本书又优于解题题典,不仅展示解题过程,更详细地提供了解题思考过程和切入点的选择方法,教方法导引思路的功能更强。 学生要提高解题能力,必须具备两个条件:一是打好基础,二是能够运动所学知识分析问题和解决问题。本书用例题解析解说知识点、重点、难点和考点,同时提供解题思考过程,在打基础中激活能力,在解题实......一起来看看 《八年级数学(华东师大版)-解题升级-解题快速反应一本通(新课标)》 这本书的介绍吧!

SHA 加密
SHA 加密

SHA 加密工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换