⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 6-5-2.txt

📁 java入门的几个代码,很实用,初学者不可错过
💻 TXT
字号:
import java.awt.*;
import java.awt.event.*;
import borland.jbcl.layout.*;
import borland.jbcl.control.*;
import java.io.*;
import java.util.*;
public class MainFrame extends Frame
{
TextField textField1 =new TextField();
Button button1=new Button();
Label labe11=new Label();
Label labe12=new Label();
TextField textField2=new TextField();
Button button2 =new Button();
Button button3 =new Button();
Filer filer1 =new Filer(this,″this,选择源文件″,Filer.LOAD);
Filer filer2 =new Filer(this,″this,选择目的文件″,Filer.SAVE); 
Button button4= new Button();
Label labe13 =new Label();
Panel pane11 =new Panel();
PaneLayout paneLayout1=new PaneLayout();
PaneLayout paneLayout2=new PaneLayout();
GroupBox groupBox1=new GroupBox();   
List list1=new List(); 
PaneLayout paneLayout3=new PaneLayout();
Public MainFrame() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.setSize(new Dimension(454,154));
this.setBackground(new Color(192,192,192));
button1.setLabel(″浏览″...″);
button1.addActionListener(new MainFrame_button1_actionAdapter(this));
button1.addActionListener(new MainFrame_button1_actionAdapter(this));
labell.setAlignmetnt(2);
labell.setText(″源文件:″); 
labe12.setAlignement(2); 
label2.setText(″目的文件″);
button2.setLabel(″复制″);
button3.addActionListener(new MainFrame_button2_actionAdapter(this));
button3.setLabel(″退出″);
button3.addAactionListener(new MainFrame_button3_actionAdapter(this));button3.setLabel(″浏览″...);
button4.addActionListerer(new MainFrame_button3_actionAdapter(this));
label3.setText(“请输入或选择源文件(夹)和目标文件(夹):”);
groupBox1.setLayout(panLayout3);
groupBox1.setLablel(″下载队列″);
this.setLayout(paneLayoutl); 
this.add(pane11,new PaneConstraints 
(″panell″, ″panell″,PaneConstraints.ROOT,0.51)); 
pane11.add(groupBox1.new PaneConstraints 
(“groupBox1”,“groupBox1”,PaneConstraints.ROOT,1.0f));
groupBox1.add(list1,new PaneConstraints 
(″list1″, ″list1″,PaneConstraints.ROOT, 1.0f));
this.add(labe13,new PaneConstraints
(“label3”, “panell” ,PaneConstraints.LEFT, 0.6300448f);
this.add(labe11,newPaneConstraints(“labe11”,“labe13”,PaneConstraints.BOTTOM, 0.68589747f); 
this.add(label2.newPaneConstraints(“labe12”,“label11”,PaneConstraints.BOTTOM, 0.6730769f); 
this.add(textField1,newPaneConstraints(“textField1”,PaneConstrains.RIGHT, 0.76868325f);
this.add(button1.newPaneConstraints(“button1”,“textField1”,PaneConstraints,RIGHT,0.3442623f); 
this.add(textField2,newPaneConstraints(“textField2”,“label2,PaneConstraints.RIGHT,0.76868325f); 
this.add(button4,newPaneConstraints(“button4”,“textField2”,PaneConstraints.RIGHT,0.3442623f); 
this.add(button3,new PaneConstraints
(“button3”,“buttonon2”,PaneConstraints.RIGHT,0.4798851f); 
} 
public static  void main(String[]args)  {
   MainFrame frame=new MainFrame();
   Frame.setLocation(200,200);
   Frame.setSize(450,150);
   Frame.show();
   }
void button1_actionPerformed(ActionEvent e)  {
filer.show();    //粗体为所添加的代码
String dir=filer1.getDirectory();
String file=filer1.getFile();
if(dir.equals(″null″)&&file.equals(″null″))return;
textField1.setText(dir+file);
  }
  void button2_actionPerformed(ActionEvent e) {
   String sourceName=textField1.getText();
   String desName=textField2.getText();
if(sourceName.equals(“”‖desName.equals(“”))retrun;
   pCopyFile=new PrepareCopyFile(this.sourceName,desName);
   pCopyFile.start();
 } 
void button3_actionPerformed(ActionEvent e) 
{ 
messageDialog mdlg=new MessageDialog 
(this, ″警告″,″确定要退出吗?″,6);\
mdlg.setSize(150.80);
  mdlg.show();
  if(mdlg.gteResult()==MessageDialog.NO)
  retrun;
System.exit(0);
}
void button4_actionPerformed(ActionEvent e) {
  filer2.show();
  String dir=filer2.getDirectory();
  String file=filer2.getFile();
  if(dir.eqals(″null″)&&file.equals(″null″))reurn;
  textField2.setText(dir+file);
}
} 

⌨️ 快捷键说明

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