黑马程序员 【】java学习之路——GUI开始简析三
2014-08-19 17:59
183 查看
-------
android培训、java培训、期待与您交流! ----------
需求:实现如下窗口,功能:能够转到相应的盘符下显示该盘内的内容
android培训、java培训、期待与您交流! ----------
需求:实现如下窗口,功能:能够转到相应的盘符下显示该盘内的内容
<span style="font-size:18px;">import java.awt.*; import java.awt.event.*; import java.io.*; class MyWindows { private Frame f; private TextField tf; private Button b ; private TextArea ta; MyWindows() { init(); } private void init() { f = new Frame("我的窗口"); f.setBounds(300,100,600,500); f.setLayout(new FlowLayout()); tf = new TextField(50); b = new Button("转到"); ta = new TextArea(25,70); f.add(tf); f.add(b); f.add(ta); myEvent(); f.setVisible(true); } private void myEvent() { b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String dirPath = tf.getText(); File dir = new File(dirPath); if (dir.exists() && dir.isDirectory()) { ta.setText(""); String[] names = dir.list(); for(String name : names) { ta.append(name+"\r\n"); } } } }); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); } public static void main(String[] args) { new MyWindows(); } } </span>
相关文章推荐
- 黑马程序员 【】java学习之路——GUI开始简析二
- 黑马程序员 【】java学习之路——GUI开始简析
- 黑马程序员 【】java学习之路——网络编程之UDP传输简析
- 黑马程序员_JAVA学习日记_JAVA中图形化界面GUI编程
- 黑马程序员—20—java基础:有关GUI图形用户界面学习笔记和学习心得体会
- 黑马程序员 【】java学习之路——内部类和匿名内部类简介
- 黑马程序员 【】java学习之路——集合Collecton
- 黑马程序员java学习—GUI(图形用户界面)
- 黑马程序员 【】java学习之路——关键字、标识符、注释、常量和变量、数组
- 黑马程序员 【】java学习之路——异常
- 黑马程序员 【】java学习之路——单例设计模式简介
- 黑马程序员学习log第七篇基础知识:JAVA的面向对象之GUI总结
- 黑马程序员 java基础24天 GUI编程学习总结
- 黑马程序员 【】java学习之路——权限修饰简单总结
- 黑马程序员——(学习心得)刚开始接触java时的心情
- 黑马程序员---java学习笔记之GUI2
- 黑马程序员--GUI界面编程--java学习日记9(基础知识)
- 黑马程序员Java学习日记(7)GUI
- 黑马程序员 【】java学习之路——IO流使用解析
- 黑马程序员 【】java学习之路——线程