您的位置:首页 > 编程语言 > Java开发

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);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: