程序设计是给出解决特定问题程序的过程
程序设计是给出解决特定问题程序的过程,是 软件构造活动中的重要组成部分。程序设计往往以某种 程序设计语言为工具,给出这种语言下的程序。
程序设计过程应当包括 分析、 设计、 编码、测试、排错等不同阶段。
专业的程序设计人员常被称为程序员。
1 package Com.SwingTest; 2 3 4 import java.awt.Button; 5 import java.awt.Label; 6 import java.awt.List; 7 8 import java.awt.TextField; 9 import java.awt.event.ActionEvent; 10 import java.awt.event.ActionListener; 11 import javax.swing.JFrame; 12 13 public class SwingText_01 extends JFrame { 14 private List list = new List(50,true); 15 private Label le = new Label("姓 名:"); 16 private TextField tx = new TextField(); 17 private Label le2 = new Label("电话号码:"); 18 private TextField te= new TextField(); 19 private Button bt = new Button("添加"); 20 private Button bt2 = new Button("删除"); 21 public SwingText_01() { 22 setTitle("电话簿"); 23 this.le.setBounds(20, 10, 50, 20); 24 this.tx.setBounds(80, 10, 100, 20); 25 this.le2.setBounds(200, 10, 60, 20); 26 this.te.setBounds(260, 10, 100, 20); 27 this.bt.setBounds(380, 10, 50, 20); 28 this.bt2.setBounds(450, 10,50, 20); 29 this.list.setBounds(10, 50, 500, 400); 30 this.list.add("姓名"+" "+"电话号码"); 31 this.list.add("张X"+" "+"186177777"); 32 this.list.add("刘X"+" "+"187777777",2); 33 this.list.setMultipleMode(false); 34 this.setLayout(null); 35 this.add(this.list); 36 this.add(this.le2); 37 this.add(this.te); 38 this.add(this.le); 39 this.add(this.tx); 40 this.add(this.bt); 41 this.add(this.bt2); 42 this.setSize(540, 400); 43 this.setLocation(100, 100); 44 this.setVisible(true); 45 46 } 47 public static void main(String[] args) { 48 final SwingText_01 j1 = new SwingText_01(); 49 j1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 50 j1.bt.addActionListener(new ActionListener() { 51 52 public void actionPerformed(ActionEvent e) { 53 String name = j1.tx.getText(); 54 String phone = j1.te.getText(); 55 j1.list.add(name+" "+phone); 56 j1.tx.setText(null); 57 j1.te.setText(null); 58 } 59 }); 60 j1.bt2.addActionListener(new ActionListener() { 61 62 public void actionPerformed(ActionEvent e) { 63 // TODO Auto-generated method stub 64 int a = j1.list.getSelectedIndex(); 65 66 } 67 }); 68 } 69 }