日期:2014-05-20 浏览次数:20815 次
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TestFrame extends Frame { public TestFrame(String s) { super(s); setLayout(null); TextField t_File_Name = new TextField(); Toolkit tool = getToolkit(); Dimension dim = tool.getScreenSize(); setBounds(dim.width / 3, dim.height / 3, dim.width / 3, dim.height / 3); add(t_File_Name); t_File_Name.setBounds(20, 20, 24, 8); setVisible(true); } public static void main(String[] args) { Frame frame = new TestFrame("Hello,World!"); frame.setSize(400, 300); frame.setVisible(true); //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { System.exit(0); } }); } }