Java 实验8_1
2008-01-28 08:24
375 查看
/*
* @(#)DrawNamesTest
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab8.Lab8_1;
/**
* 调用Frame
* @version 1.0.0.0 Jan 27, 2008
* @author eleven
*/
public class DrawNamesTest {
public static void main(String[] args) {
NamesFrame namesFrame = new NamesFrame();
}
}
/*
* @(#)NamesFrame
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab8.Lab8_1;
import javax.swing.JFrame;
/**
* 实验8第一个 设置一个Frame
* @version 1.0.0.0 Jan 27, 2008
* @author eleven
*/
public class NamesFrame extends JFrame {
public static final int DEFAULT_WIDTH = 500;
public static final int DEFAULT_HEIGHT = 500;
public NamesFrame() {
super("Display Name");
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
NamesPanel namesPanel = new NamesPanel();
setContentPane(namesPanel);
setVisible(true);
}
}
/*
* @(#)NamesPanel
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab8.Lab8_1;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.JPanel;
/**
* 实验8第一个 设置一个Panel并在上面添加内容
* @version 1.0.0.0 Jan 27, 2008
* @author eleven
*/
public class NamesPanel extends JPanel {
public NamesPanel() {
for (int i = 4; i <= 24; i++) {
Font f = new Font("Serial", Font.BOLD, i);
JLabel nameLabel = new JLabel("Eleven");
nameLabel.setFont(f);
nameLabel.setForeground(Color.RED);
add(nameLabel);
}
}
}
-----------------
测试
/*
* @(#)DrawNamesTestTest
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab8.Lab8_1;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* 实验8 第一个测试用例
* @version 1.0.0.0 Jan 28, 2008
* @author eleven
*/
public class DrawNamesTestTest {
public DrawNamesTestTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of main method, of class DrawNamesTest.
*/
@Test
public void main() {
System.out.println("main");
String[] args = null;
DrawNamesTest.main(args);
}
}
* @(#)DrawNamesTest
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab8.Lab8_1;
/**
* 调用Frame
* @version 1.0.0.0 Jan 27, 2008
* @author eleven
*/
public class DrawNamesTest {
public static void main(String[] args) {
NamesFrame namesFrame = new NamesFrame();
}
}
/*
* @(#)NamesFrame
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab8.Lab8_1;
import javax.swing.JFrame;
/**
* 实验8第一个 设置一个Frame
* @version 1.0.0.0 Jan 27, 2008
* @author eleven
*/
public class NamesFrame extends JFrame {
public static final int DEFAULT_WIDTH = 500;
public static final int DEFAULT_HEIGHT = 500;
public NamesFrame() {
super("Display Name");
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
NamesPanel namesPanel = new NamesPanel();
setContentPane(namesPanel);
setVisible(true);
}
}
/*
* @(#)NamesPanel
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab8.Lab8_1;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.JPanel;
/**
* 实验8第一个 设置一个Panel并在上面添加内容
* @version 1.0.0.0 Jan 27, 2008
* @author eleven
*/
public class NamesPanel extends JPanel {
public NamesPanel() {
for (int i = 4; i <= 24; i++) {
Font f = new Font("Serial", Font.BOLD, i);
JLabel nameLabel = new JLabel("Eleven");
nameLabel.setFont(f);
nameLabel.setForeground(Color.RED);
add(nameLabel);
}
}
}
-----------------
测试
/*
* @(#)DrawNamesTestTest
*
* Copyright 2008 School of Software, Yunnan University.
* All rights reserved
*/
package cn.edu.ynu.sei.Java_Labs.Lab8.Lab8_1;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* 实验8 第一个测试用例
* @version 1.0.0.0 Jan 28, 2008
* @author eleven
*/
public class DrawNamesTestTest {
public DrawNamesTestTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of main method, of class DrawNamesTest.
*/
@Test
public void main() {
System.out.println("main");
String[] args = null;
DrawNamesTest.main(args);
}
}
相关文章推荐
- Java 2实用教程(第三版)实验指导与习题解答and实验模版代码及答案 (三)
- Java第6章-接口与多态-实验一(作战命令)
- java 第五周实验【报告1】
- java 第五周实验【报告3】
- Java 引用传递的实验
- 20145220 实验五 Java网络编程
- JAVA--第六周实验--任务1--Java的对象封装编程练习
- JAVA--第五周实验--任务6--封装一类矩阵对象,完成矩阵中数据的位置变换、加法、乘法的功能
- java第四次实验报告
- Java实验报告五
- JAVA第四次实验
- 实验五 Java网络编程及安全
- Java汉化实验项目求小伙伴
- Java 垃圾回收测试小实验
- java实验一实验报告
- java实验一报告
- java程序-编译原理实验
- 20155230 《Java程序设计》实验一(Java开发环境的熟悉) 实验报告
- 哈工大 java实验4 基于socket的消息发送与文件传输
- java初始化顺序实验代码