zuoye3.java

来自「主要完成一些窗口的建立」· Java 代码 · 共 46 行

JAVA
46
字号
/* * To change this template, choose Tools | Templates * and open the template in the editor. *//** * * @author Administrator */import java.awt.*;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;import javax.swing.*;import java.awt.event.*;public class ZuoYe3  extends JFrame implements ActionListener{  JButton button;   JTextArea text ;   public ZuoYe3(){  JPanel p1=new JPanel();  JPanel p2=new JPanel();  Container container= getContentPane();   container.setLayout(new BorderLayout());   p2.setLayout(new BorderLayout());   p1.setLayout(new FlowLayout());   p1.add(button=new JButton("Open file"));   container.add(p1,BorderLayout.NORTH);   container.add(text=new JTextArea(),BorderLayout.CENTER);     button.addActionListener(this);   }      public void actionPerformed(ActionEvent e){       if(e.getSource() == button){       FileDialog d=new  FileDialog(new ZuoYe3()," FileDialog ");       d.setVisible(true);       String fiilename=d.getFile();       text.append(d.getDirectory()+"\n");       }      }        public static void main(String[] args){        ZuoYe3 frame=new  ZuoYe3();        frame.setTitle("example");        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        frame.setSize(400,250);        frame.setVisible(true);}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?